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
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
===================================================================
--- original.js
+++ change.js
@@ -211,9 +211,9 @@
var currentShootBuckets = 0;
var maxSpeed = 100;
var ballPassedAboveHoop = false;
var ballPassedInsideHoop = false;
-var timerSeconds = 6; // Set the initial timer value in seconds
+var timerSeconds = 60; // Set the initial timer value in seconds
var ball = null;
var hoop = null;
var score = 0;
var startPosition = null;
@@ -223,17 +223,16 @@
var scoreTxt = null;
var timerTxt = null;
var minShootSpeed = 30;
var timerInterval = null;
-var timerOriginalWeigth = 0;
-var timerOriginalHeight = 0;
+var timerOriginalWeigth = 94; // 1 number
+var timerOriginalHeight = 174;
/* ********************************************************************************* */
/* ******************************* INPUT HANDLERS ********************************** */
/* ********************************************************************************* */
game.on('down', function (obj) {
var pos = obj.event.getLocalPosition(game);
startPosition = pos;
- bounceMultiplier = 1;
});
game.on('up', function (obj) {
if (startPosition && !ball.isMoving) {
var endPosition = obj.event.getLocalPosition(game);
@@ -295,10 +294,8 @@
});
timerTxt.tint = timerSeconds <= 5 ? 0xff0000 : 0x646464;
timerTxt.anchor.set(1.15, -0.250);
LK.gui.topRight.addChild(timerTxt);
- 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)
@@ -403,8 +400,26 @@
isHandlingScore = true;
currentShootBuckets++;
score += 10 * bounceMultiplier + 10 * bounceMultiplier * (currentShootBuckets - 1); // Add bounce counter to score
scoreTxt.setText(score.toString());
+ // Animate scoreTxt to briefly grow and shrink when the player scores
+ var originalSize = scoreTxt.size;
+ var maxSize = originalSize * 1.5;
+ var grow = true;
+ var animationInterval = LK.setInterval(function () {
+ if (grow) {
+ scoreTxt.size += 5;
+ if (scoreTxt.size >= maxSize) {
+ grow = false;
+ }
+ } else {
+ scoreTxt.size -= 5;
+ if (scoreTxt.size <= originalSize) {
+ scoreTxt.size = originalSize;
+ LK.clearInterval(animationInterval);
+ }
+ }
+ }, 16); // Run every 16ms (~60FPS)
popupBucket(currentShootBuckets > 1);
//ball.reset();
ballPassedAboveHoop = false; // Reset the condition after scoring
ballPassedInsideHoop = false;
@@ -445,9 +460,9 @@
// popup the asset corresponding to the value
if (value < 2) {
return;
}
- var possibleValues = [2, 4, 8, 16, 32, 64, 128, 256];
+ var possibleValues = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024];
if (!possibleValues.includes(value)) {
value = 999;
}
// Create and configure the x2 asset