/**** * Classes ****/ // Assets will be automatically created and loaded during gameplay // Ball class var Ball = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.attachAsset('ball', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = 0; self.speedY = 0; self.update = function () { self.x += self.speedX; self.y += self.speedY; // Check for collision with screen boundaries if (self.x < 0 || self.x > 2048) { self.speedX *= -1; } if (self.y < 0 || self.y > 2732) { self.speedY *= -1; } }; }); // Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); }); // Target1 class var Target1 = Container.expand(function () { var self = Container.call(this); var targetGraphics = self.attachAsset('target', { anchorX: 0.5, anchorY: 0.5 }); self.points = 1; // Default points }); // Target2 class var Target2 = Container.expand(function () { var self = Container.call(this); var targetGraphics = self.attachAsset('target2', { anchorX: 0.5, anchorY: 0.5 }); self.points = 5; // Default points }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000, // Init game with black background icon: 'new_icon_id', // Replace with the new icon id description: 'New game description' // Replace with the new game description }); /**** * Game Code ****/ var background = game.addChild(LK.getAsset('background', { anchorX: 0.0, anchorY: 0.0, width: 2048, height: 2732 })); var ball = game.addChild(new Ball()); ball.x = 1024; ball.y = 1366; var obstacles = []; var targets = []; var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); function spawnObstacle() { var obstacle = new Obstacle(); obstacle.x = Math.random() * 2048; obstacle.y = Math.random() * 2732; obstacle.creationTime = LK.ticks; obstacles.push(obstacle); game.addChild(obstacle); } function spawnTarget() { var target; if (Math.random() < 0.5) { target = new Target1(); } else { target = new Target2(); } target.x = Math.random() * 2048; target.y = Math.random() * 2732; target.creationTime = LK.ticks; targets.push(target); game.addChild(target); } function updateScore(points) { score += points; scoreTxt.setText(score); } game.down = function (x, y, obj) { var game_position = game.toLocal(obj.global); ball.speedX = (game_position.x - ball.x) / 20; ball.speedY = (game_position.y - ball.y) / 20; }; game.update = function () { for (var i = obstacles.length - 1; i >= 0; i--) { if (ball.intersects(obstacles[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } if (LK.ticks - obstacles[i].creationTime > 600) { obstacles[i].destroy(); obstacles.splice(i, 1); } } for (var j = targets.length - 1; j >= 0; j--) { if (ball.intersects(targets[j])) { updateScore(targets[j].points); targets[j].destroy(); targets.splice(j, 1); } if (targets[j] && (targets[j] instanceof Target1 && LK.ticks - targets[j].creationTime > 600 || targets[j] instanceof Target2 && LK.ticks - targets[j].creationTime > 300)) { targets[j].destroy(); targets.splice(j, 1); } } if (LK.ticks % 120 == 0) { spawnObstacle(); } if (LK.ticks % 180 == 0) { spawnTarget(); } };
===================================================================
--- original.js
+++ change.js
@@ -53,9 +53,13 @@
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000 // Init game with black background
+ backgroundColor: 0x000000,
+ // Init game with black background
+ icon: 'new_icon_id',
+ // Replace with the new icon id
+ description: 'New game description' // Replace with the new game description
});
/****
* Game Code
红色炸弹. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
金币. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
钻石. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
黄色吃豆人. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.