Code edit (5 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Set the joystick invisible in gameinitialze and show it when game starts
User prompt
Hide the joystick in gameinitialze and show it when game starts
Code edit (13 edits merged)
Please save this source code
User prompt
Move startButton init to the end of gameinitalize
User prompt
In game down handler you can destroy startButton
User prompt
Add a gameStarted = false and a startButton = nulll globals. In gameInitialize, init startButton with a new « startButton » asset. In game.down handler, if !gameStarted, set gameStarted to true and hide startButton else set joystickDrag to true.
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -81,24 +81,25 @@
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 1,
- alpha: 0.92,
+ alpha: 0.98,
scaleX: index === 2 ? -1 : 1,
tint: index === 1 ? 0xADD8E6 : 0xFF6347 // Light blue for player 1, Tomato red for player 2
});
self.index = index;
self.scale.set(1, 1); // Initialize player scale to normal
self.jumping = false;
self.falling = false;
self.speedX = 0; // Initialize horizontal speed
- var collidSize = 240;
+ var collidSize = 245;
self.collisionBody = LK.getAsset('collisionBody', {
anchorX: 0.5,
anchorY: 0.5,
alpha: isDebug ? 0.6 : 0,
width: collidSize,
height: collidSize,
+ x: 0,
y: -200
});
self.addChild(self.collisionBody);
self.update = function () {
@@ -150,17 +151,19 @@
var PLAYER2_INITIAL_X = 1792;
var BALL1_INITIAL_X = 640;
var BALL_INITIAL_Y = 1256;
var BALL2_INITIAL_X = 1408;
+var gameStarted = false;
+var startButton = null;
var joystick;
var joystickBasePosition;
var joystickDrag;
var touchTime; // Global variable to store the touch time
var prevMouseY;
var lastPlayedTime;
var ballCanMove;
var SPEED_LIMIT; // Define a global speed limit
-var isDebug = true;
+var isDebug = false;
var player2Debug;
var player1Touches;
var player2Touches;
var resetTime; // Global variable to store the reset time
@@ -408,9 +411,14 @@
}
updateShadows();
};
game.down = function (x, y, obj) {
- joystickDrag = true;
+ if (!gameStarted) {
+ gameStarted = true;
+ startButton.visible = false;
+ } else {
+ joystickDrag = true;
+ }
};
game.move = function (x, y, obj) {
if (Date.now() - resetTime < nextRoundPauseDelay) {
return;
@@ -431,8 +439,15 @@
y: 2732 / 2
});
game.addChild(background);
initShadows();
+ startButton = LK.getAsset('startButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2
+ });
+ game.addChild(startButton);
var parasol = LK.getAsset('parasol', {
anchorX: 0.5,
anchorY: 1,
x: 1848,
@@ -518,9 +533,9 @@
player2Debug = false;
player1Touches = 0;
player2Touches = 0;
resetTime = 0; // Global variable to store the reset time
- nextRoundPauseDelay = 1000;
+ nextRoundPauseDelay = 1500;
score1 = 0;
score2 = 0;
scoreTxt1.setText(score1.toString().padStart(2, '0'));
scoreTxt2.setText(score2.toString().padStart(2, '0'));
white volley ball.
top view of a concave blue (0xADD8E6) plastic button. 4 small black directionnal chevrons engraved : right, left, top , bottom.. Photorealistic
Beach ball. photo
full view of a Beach white towel with colored infinte logo. placed on the sand. photo
Start button in the shape of a white beach volleyball with « START » written on it in black. Photo