User prompt
on game start power ups should start ascending
User prompt
spawn power ups coming down up in the same line as the player
User prompt
make circle 50% transparent
User prompt
Please fix the bug: 'Uncaught TypeError: Graphics is not a constructor' in or related to this line: 'var circle = new Graphics();' Line Number: 18
User prompt
add a circle arround the player
User prompt
Add player in the center of the screen
Initial prompt
Empty game
===================================================================
--- original.js
+++ change.js
@@ -14,8 +14,22 @@
anchorY: 0.5,
alpha: 0.5
});
});
+// Create a PowerUp class
+var PowerUp = Container.expand(function () {
+ var self = Container.call(this);
+ var powerUpGraphics = self.attachAsset('powerUp', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Set powerUp speed
+ self.speed = 5;
+ // This is automatically called every game tick, if the powerUp is attached!
+ self.update = function () {
+ self.y += self.speed;
+ };
+});
/****
* Initialize Game
****/
@@ -29,7 +43,17 @@
/****
* Game Code
****/
// Add player to the game
+// Keep track of powerUps using an array
+var powerUps = [];
+// Spawn powerUps every 60 game ticks
+if (LK.ticks % 60 == 0) {
+ var newPowerUp = new PowerUp();
+ newPowerUp.x = player.x;
+ newPowerUp.y = 0;
+ powerUps.push(newPowerUp);
+ game.addChild(newPowerUp);
+}
var player = game.addChild(new Player());
player.x = 2048 / 2; // Center player horizontally
player.y = 2732 / 2; // Center player vertically
\ No newline at end of file