Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
in swipeAnim, separate the target setting and the asset movement
Code edit (6 edits merged)
Please save this source code
User prompt
in swipeAnim, update the rotation of the asset toward the target
User prompt
in swipeAnim, alternate the targetX each time between these values: 1*game.width *0.25 2*game.width *0.25 3*game.width *0.25
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
implement swipeAnim, bt adding the swipe asset and make it move infinetly from ball to the center of the screen
Code edit (1 edits merged)
Please save this source code
User prompt
implement animateScore with wdith and height grow and restore of scoreTxt
Code edit (7 edits merged)
Please save this source code
User prompt
animate scoreTxt when player scores
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
add a little label "Score" above the scoreTxt
Code edit (1 edits merged)
Please save this source code
User prompt
in animateTimer make size bump
User prompt
in animateTimer make size increase then decrease each sec
User prompt
in handleTimer , when time is under 5, animate timerTxt width and height
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: timerInterval is not defined' in or related to this line: 'LK.clearInterval(timerInterval); // Stop the timer when it reaches 0' Line Number: 321
Code edit (2 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -211,10 +211,9 @@
var currentShootBuckets = 0;
var maxSpeed = 100;
var ballPassedAboveHoop = false;
var ballPassedInsideHoop = false;
-var timerSeconds = 60;
-60; // Set the initial timer value in seconds
+var timerSeconds = 6; // Set the initial timer value in seconds
var ball = null;
var hoop = null;
var score = 0;
var startPosition = null;
@@ -224,8 +223,10 @@
var scoreTxt = null;
var timerTxt = null;
var minShootSpeed = 30;
var timerInterval = null;
+var timerOriginalWeigth = 0;
+var timerOriginalHeight = 0;
/* ********************************************************************************* */
/* ******************************* INPUT HANDLERS ********************************** */
/* ********************************************************************************* */
game.on('down', function (obj) {
@@ -283,22 +284,23 @@
weight: 1000,
dropShadow: true
});
timerLabelTxt.tint = 0x646464;
- timerLabelTxt.anchor.set(1.25, 0.25);
+ timerLabelTxt.anchor.set(1.4, 0.25);
LK.gui.topRight.addChild(timerLabelTxt);
timerTxt = new Text2(timerSeconds.toString(), {
size: 150,
fill: "#FFFFFF",
weight: 1000,
dropShadow: true
});
timerTxt.tint = timerSeconds <= 5 ? 0xff0000 : 0x646464;
- timerTxt.anchor.set(1, -0.250);
+ timerTxt.anchor.set(1.15, -0.250);
LK.gui.topRight.addChild(timerTxt);
- timerTxt.width = 200;
- timerTxt.height = 200;
- timerTxt.tint = 0xff0000;
+ timerOriginalWeigth = timerTxt.width;
+ timerOriginalHeight = timerTxt.height;
+ console.log("timerOriginalWeigth", timerOriginalWeigth);
+ console.log("timerOriginalHeight", timerOriginalHeight);
// Update the timer every second
timerInterval = LK.setInterval(handleTimer, 1000); // Set the interval to update every 1000ms (1 second)
ball = game.addChild(new Ball());
ball.reset();
@@ -315,23 +317,27 @@
function handleTimer() {
timerSeconds -= 1; // Decrement the timer by one second
timerTxt.setText(timerSeconds.toString()); // Update the timer display with conditional color change
var animateTimer = null;
- if (timerSeconds <= 5) {
+ if (timerSeconds <= 5 && timerSeconds > 0) {
+ var maxTimerLabelSize = 200 + (5 - timerSeconds) * 20;
timerTxt.tint = 0xff0000;
// Animate timerTxt width and height
var growDirection = 1;
animateTimer = LK.setInterval(function () {
timerTxt.width += growDirection * 4;
timerTxt.height += growDirection * 4;
- if (timerTxt.width >= 200 || timerTxt.height >= 200 || timerTxt.width <= 100 || timerTxt.height <= 100) {
+ if (timerTxt.width >= maxTimerLabelSize || timerTxt.height >= maxTimerLabelSize || timerTxt.width <= 100 || timerTxt.height <= 100) {
growDirection *= -1;
}
}, 16); // Run every 16ms (~60FPS)
} else {
timerTxt.tint = 0x646464;
}
if (timerSeconds <= 0) {
+ timerTxt.tint = 0x646464;
+ timerTxt.width = timerOriginalWeigth;
+ timerTxt.height = timerOriginalHeight;
LK.clearInterval(animateTimer);
LK.clearInterval(timerInterval); // Stop the timer when it reaches 0
LK.setScore(score); // Save the final score using the platform's tool
LK.showGameOver(); // Show game over screen
@@ -395,9 +401,9 @@
}
console.log("handleScore...bounceMultiplier=", bounceMultiplier, "*", currentShootBuckets);
isHandlingScore = true;
currentShootBuckets++;
- score += bounceMultiplier + bounceMultiplier * (currentShootBuckets - 1); // Add bounce counter to score
+ score += 10 * bounceMultiplier + 10 * bounceMultiplier * (currentShootBuckets - 1); // Add bounce counter to score
scoreTxt.setText(score.toString());
popupBucket(currentShootBuckets > 1);
//ball.reset();
ballPassedAboveHoop = false; // Reset the condition after scoring
@@ -408,9 +414,9 @@
confetti.y = 0;
LK.on('tick', function () {
confetti.animate(); // Animate confetti
});
- /*
+ /*
LK.setTimeout(function () {
isHandlingScore = false;
resetCollisionHandling();
},250);