Code edit (4 edits merged)
Please save this source code
User prompt
add a delay between the shake effect of each coin so they are not perfectly syncronized
User prompt
add a delay between the shake effect of each coin so they are not perfectly syncronized
Code edit (11 edits merged)
Please save this source code
User prompt
add a shake or vibrate effect to the coins
Code edit (1 edits merged)
Please save this source code
User prompt
the spawners are placed exactly at the edge of the screen, making the coins seem to pop out of nowhere, move them 50 pixels outside the edge of the screen so the coins are generated outside the screen bounds
User prompt
create a new background asset nd stretch it across the entire size of the screen. add it to the backgroundcontainer
Code edit (1 edits merged)
Please save this source code
User prompt
the text writing is aligned to the left, which means the value extends towards the right, it should instead be aligned to the center so the text always remaines centered regardless of the digits it contains
Code edit (3 edits merged)
Please save this source code
User prompt
add a black outline to the score and ensure its alignment is to the center instead of to the left
Code edit (10 edits merged)
Please save this source code
User prompt
align the score perfectly to the center of the screen
User prompt
add a score text in the center of the screen and place it in the midground container
User prompt
place the spawners in the foregroundcontainer
Code edit (1 edits merged)
Please save this source code
User prompt
reverse the x axis of the coins. so the ones generated on the left have a certain x axis, reverse it, and do the same for the ones on the right
User prompt
flip the X axis of the coins that are generated at the left side of the screen
User prompt
flip the X axis of the coins that are generated at the left side of the screen
User prompt
the game starts lagging after a while, telling me coins are not properly disposed off. ensure you recycle them, so once they go out of the screen, you recycle them
User prompt
Coins should be collectable and increment the score by 1 each
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'var spawner = midgroundContainer.addChild(new SpawnerLeft(60 * (i + 1), 2732 / 7 * i + 500));' Line Number: 189
User prompt
create a BackgroundContainer, MidgroundContainer and ForegroundContainer in that order
User prompt
when the player touches a coin, collect it and add +1 point to the score
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,12 @@
/****
* Classes
****/
+// Define the BackgroundContainer class
+var BackgroundContainer = Container.expand(function () {
+ var self = Container.call(this);
+ return self;
+});
// Define the Coin class
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
@@ -26,8 +31,13 @@
self.x += self.speed;
};
return self;
});
+// Define the ForegroundContainer class
+var ForegroundContainer = Container.expand(function () {
+ var self = Container.call(this);
+ return self;
+});
// Define the Life class
var Life = Container.expand(function () {
var self = Container.call(this);
var lifeGraphics = self.attachAsset('Life', {
@@ -46,8 +56,13 @@
}
};
return self;
});
+// Define the MidgroundContainer class
+var MidgroundContainer = Container.expand(function () {
+ var self = Container.call(this);
+ return self;
+});
//<Assets used in the game will automatically appear here>
// Define the Player class
var Player = Container.expand(function () {
var self = Container.call(this);
@@ -146,22 +161,8 @@
}
};
return self;
});
-// Define the Score class
-var Score = Text2.expand(function () {
- var self = Text2.call(this, '0', {
- size: 150,
- fill: "#ffffff",
- stroke: "#000000",
- strokeThickness: 5,
- anchorX: 0.5,
- anchorY: 0.5,
- x: 2048 / 2,
- y: 2732 / 2
- });
- return self;
-});
/****
* Initialize Game
****/
@@ -174,23 +175,24 @@
****/
// Create the spawners on the right side of the screen
var spawnersLeft = [];
for (var i = 0; i < 5; i++) {
- var spawner = game.addChild(new SpawnerLeft(60 * (i + 1), 2732 / 7 * i + 500));
+ var spawner = midgroundContainer.addChild(new SpawnerLeft(60 * (i + 1), 2732 / 7 * i + 500));
spawnersLeft.push(spawner);
}
-var player = game.addChild(new Player());
-var life = game.addChild(new Life());
+var backgroundContainer = game.addChild(new BackgroundContainer());
+var midgroundContainer = game.addChild(new MidgroundContainer());
+var foregroundContainer = game.addChild(new ForegroundContainer());
+var player = foregroundContainer.addChild(new Player());
+var life = foregroundContainer.addChild(new Life());
player.x = 2048 / 2;
player.y = 2732 - player.height;
// Create the spawners
var spawners = [];
for (var i = 0; i < 5; i++) {
- var spawner = game.addChild(new Spawner(60 * (i + 1), 2732 / 7 * i + 700));
+ var spawner = midgroundContainer.addChild(new Spawner(60 * (i + 1), 2732 / 7 * i + 700));
spawners.push(spawner);
}
-// Create a score object and add it to the GUI overlay
-var score = LK.gui.center.addChild(new Score());
game.down = function (x, y, obj) {
player.startJump();
LK.getSound('Charge').play();
player.shake = true;
@@ -215,16 +217,6 @@
if (player.intersects(life)) {
life.destroy();
life = game.addChild(new Life());
}
- // Increase the score by 1 when a coin is collected
- for (var i = game.children.length - 1; i >= 0; i--) {
- var child = game.children[i];
- if (child instanceof Coin || child instanceof CoinLeft) {
- if (player.intersects(child)) {
- child.destroy();
- score.setText(parseInt(score.text) + 1);
- }
- }
- }
life.update();
};
\ No newline at end of file
pixelated 8-bit cute sitting frog seen from the front. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelated 8-bit cute jumping frog seen from the front. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
background of a pond in the middle of the nature. pixelated 8-bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.