Code edit (1 edits merged)
Please save this source code
Code edit (22 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: center is not defined' in or related to this line: 'var instructionsTxt = new Text2('Welcome to space, traveler!\nTap to collect the color indicated below.', {' Line Number: 426
Code edit (1 edits merged)
Please save this source code
Code edit (12 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Error: The supplied index is out of bounds' in or related to this line: 'game.setChildIndex(counter, game.children.length);' Line Number: 249
Code edit (9 edits merged)
Please save this source code
User prompt
can you update this line, so it updates the textlabel with the new value
Code edit (1 edits merged)
Please save this source code
Code edit (18 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: sel is not defined' in or related to this line: 'self.x = sel.x;' Line Number: 24
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 (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: particleGraphics is not defined' in or related to this line: 'if (particleGraphics.alpha <= 0) {' Line Number: 247
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
please implement it that way
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: movetype is not defined' in or related to this line: 'if (movetype == 0) {' Line Number: 119
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 (12 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -9,20 +9,25 @@
anchorX: 0.5,
anchorY: 0,
align: 'center'
});
- self.val = 10;
+ self.val = counterMax;
self.addChild(txt);
self.init = function (index) {
//var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
//self.width = game.width / (currentPalette.length - 1) / 2;
//self.height = self.width / 2;
- self.x = selector.x + 30;
+ self.x = selector.x + 50;
self.y = game.height - 160;
+ self.val = counterMax;
+ txt.setText('' + self.val);
};
self.update = function () {
self.val -= 1;
txt.setText('' + self.val);
+ if (self.val <= 0) {
+ LK.showGameOver();
+ }
};
});
// Particle class for explosion effect
var Particle = Container.expand(function () {
@@ -197,17 +202,15 @@
self.x = centerX + self.vx * self.z;
//self.x += Math.cos(LK.ticks % 100) * 10;
self.y -= 4;
}
- if (!false) {
- // Scale star based on z position to simulate 3D effect
- var scale = Math.min(1000 / (1000 + self.z), 1.5); // Limit maximum scale to 1.5 to prevent abrupt size changes
- //scale = Math.max((1000 + self.z) / 1000, 1.5); // Limit maximum scale to 1.5 to prevent abrupt size changes
- scale = self.z / 5000;
- //scale = Math.max(self.z / 10000, 1);
- self.scale.x = scale;
- self.scale.y = scale;
- }
+ // Scale star based on z position to simulate 3D effect
+ var scale = Math.min(1000 / (1000 + self.z), 1.5); // Limit maximum scale to 1.5 to prevent abrupt size changes
+ //scale = Math.max((1000 + self.z) / 1000, 1.5); // Limit maximum scale to 1.5 to prevent abrupt size changes
+ scale = self.z / 5000;
+ //scale = Math.max(self.z / 10000, 1);
+ self.scale.x = scale;
+ self.scale.y = scale;
};
self.on('down', function (obj) {
// If player clicked the right color.
if (self.getChildAt(0).tint == currentPalette[currentRightColor]) {
@@ -234,8 +237,12 @@
} else {
// Move selector to next color on palette.
selector.init(currentRightColor);
}
+ counter.init();
+ game.setChildIndex(counter, game.children.length - 1);
+ //game.getChildByName('counter').setDepth(game.getChildByName('selector').getDepth() + 1);
+ //console.log(game.getChildByName('selector').getDepth());
// Re-init this star.
self.x = -50000;
} else {
console.log('wrong');
@@ -367,15 +374,8 @@
tweenProgress = 0;
targetX = game.width - pos.x;
targetY = game.height - pos.y;
});
-LK.on('tick', function () {
- if (tweenProgress < tweenDuration) {
- centerX += (targetX - centerX) / (tweenDuration - tweenProgress);
- centerY += (targetY - centerY) / (tweenDuration - tweenProgress);
- tweenProgress++;
- }
-});
var particles = [];
var stars = [];
for (var i = 0; i < 100; i++) {
// Increase star count for denser starfield
@@ -407,8 +407,9 @@
initSquares();
var selector = new Selector();
selector.init(0);
game.addChild(selector);
+var counterMax = 10;
var counter = new Counter();
counter.init(selector);
game.addChild(counter);
var currentRightColor = 0;
@@ -426,10 +427,10 @@
//console.log(particles.length);
stars.forEach(function (star, index) {
star.move();
});
- console.log(LK.ticks);
- if (LK.ticks % 100 == 0) {
+ //console.log(LK.ticks);
+ if (LK.ticks > 0 && LK.ticks % 100 == 0) {
counter.update();
}
particles.forEach(function (particle, index) {
particle.move();
@@ -437,5 +438,10 @@
particles.splice(index, 1);
particle.destroy();
}
});
+ if (tweenProgress < tweenDuration) {
+ centerX += (targetX - centerX) / (tweenDuration - tweenProgress);
+ centerY += (targetY - centerY) / (tweenDuration - tweenProgress);
+ tweenProgress++;
+ }
});
\ No newline at end of file
A white triangle pointing down.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A colorful rectangular button with the text "Play Again" with each letter in a different color picked from a nice palette.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.