Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
instantiate grass at the bottom of the playspace
Code edit (2 edits merged)
Please save this source code
User prompt
// Initialize the player object and position it outside the screen var player = game.addChild(new Player()); player.x = -player.width; player.y = 2732 - player.height; // Initialize the sparkles object but do not position it yet var sparkles = game.addChild(new Sparkles()); game.update = function () { // Move the player towards the right if (player.x < 250) { player.x += 5; } // Continuously position sparkles at the center of the player sparkles.x = player.x + player.width / 2 - sparkles.width / 2; sparkles.y = player.y + player.height / 2 - sparkles.height / 2; };
User prompt
and then center it with player
User prompt
Initialize the sparkles object and position it outside the screen as well
User prompt
sparkles should be animated as well with the player
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'sparkles.x = player.x + player.width / 2 - sparkles.width / 2;' Line Number: 41
User prompt
sparkles should be behind player not infront
Code edit (1 edits merged)
Please save this source code
User prompt
Make sure sparkles is centered with the players image
User prompt
Similar to player, sparkles should also be animated during the intro
User prompt
Instantiate sparkles in the center of player
Code edit (2 edits merged)
Please save this source code
User prompt
the player should move more towards the right
User prompt
the intro animation is not long enough
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,8 @@
/****
* Classes
****/
+// TRY MOVING PLAYER AFTER SPARKLES, THE CODE ALWAYS RESETS! (BEN/JOSH)
// Create a Player class by using the LK expand method to extend Container.
var Player = Container.expand(function () {
var self = Container.call(this);
// Get and automatically addChild to self asset with id 'Player' with the anchor point set to .5, .5
@@ -33,15 +34,16 @@
// Initialize the player object and position it outside the screen
var player = game.addChild(new Player());
player.x = -player.width;
player.y = 2732 - player.height;
-// Instantiate sparkles in the center of player
-var sparkles = game.addChild(new Sparkles());
-sparkles.x = player.x + player.width / 2 - sparkles.width / 2;
-sparkles.y = player.y + player.height / 2 - sparkles.height / 2 - 300;
// Ask LK engine to update game every game tick. Use this instead of Tweens
game.update = function () {
// Move the player more towards the right
if (player.x < 250) {
player.x += 5;
+ } else {
+ // Instantiate sparkles in the center of player
+ var sparkles = game.addChild(new Sparkles());
+ sparkles.x = player.x + player.width / 2 - sparkles.width / 2;
+ sparkles.y = player.y + player.height / 2 - sparkles.height / 2 - 300;
}
};
\ No newline at end of file