/**** * Classes ****/ var Ball = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.attachAsset('ball', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; }; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { var game_position = game.toLocal(obj.global); self.x = game_position.x; }; }); /**** * Initialize Game ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 - 100; var balls = []; var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); LK.gui.top.addChild(scoreTxt); game.update = function () { for (var a = balls.length - 1; a >= 0; a--) { var ball = balls[a]; if (ball.y > 2732) { ball.destroy(); balls.splice(a, 1); continue; } if (player.intersects(ball)) { LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); ball.destroy(); balls.splice(a, 1); continue; } } if (LK.ticks % 60 == 0) { var newBall = new Ball(); newBall.x = Math.random() * 2048; newBall.y = 0; balls.push(newBall); game.addChild(newBall); } }; game.move = function (x, y, obj) { var game_position = game.toLocal(obj.global); player.x = game_position.x; };
===================================================================
--- original.js
+++ change.js
@@ -67,5 +67,9 @@
newBall.y = 0;
balls.push(newBall);
game.addChild(newBall);
}
+};
+game.move = function (x, y, obj) {
+ var game_position = game.toLocal(obj.global);
+ player.x = game_position.x;
};
\ No newline at end of file
rock. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A sunset beach background with waves and palm trees.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a robotic basket with high contrast. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
robotic and shiny balls. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows