/**** * Classes ****/ var BlueBox = Container.expand(function () { var self = Container.call(this); var blueBoxGraphics = self.attachAsset('blueBox', { anchorX: 0.5, anchorY: 0.5 }); }); var Box = Container.expand(function () { var self = Container.call(this); var boxGraphics = self.attachAsset('box', { anchorX: 0.5, anchorY: 0.5 }); }); var Button = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5 }); }); var Glider = Container.expand(function () { var self = Container.call(this); var gliderGraphics = self.attachAsset('glider', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { if (self.intersects(blueBox)) { blueBox.destroy(); var snow = game.addChild(new Snow()); snow.x = self.x; snow.y = self.y; var redBox = game.addChild(new RedBox()); redBox.x = Math.random() * 2048; redBox.y = 2732; } if (self.intersects(button)) { var yellowBox = game.addChild(new YellowBox()); yellowBox.x = blueBox.x; yellowBox.y = blueBox.y; } }; }); var RedBox = Container.expand(function () { var self = Container.call(this); var redBoxGraphics = self.attachAsset('redBox', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -5; self.update = function () { self.y += self.speed; }; }); var Snow = Container.expand(function () { var self = Container.call(this); var snowGraphics = self.attachAsset('snow', { anchorX: 0.5, anchorY: 0.5 }); }); var YellowBox = Container.expand(function () { var self = Container.call(this); var yellowBoxGraphics = self.attachAsset('yellowBox', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var button = game.addChild(new Button()); button.x = 2048 - button.width / 2; button.y = 1366; var box = game.addChild(new Box()); box.x = 1024; box.y = 1366; var blueBox = game.addChild(new BlueBox()); blueBox.x = 2048 / 2; blueBox.y = 2732 / 5; var glider = game.addChild(new Glider()); glider.x = 2048 / 2; glider.y = 2732 / 2; game.move = function (x, y, obj) { glider.x = x; glider.y = y; }; game.update = function () { game.update = function () { if (!blueBox || blueBox.destroyed) { blueBox = game.addChild(new BlueBox()); blueBox.x = 2048 / 2; blueBox.y = 2732 / 5; } for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof RedBox && game.children[i].y < 0) { game.children[i].destroy(); } } }; if (!blueBox || blueBox.destroyed) { blueBox = game.addChild(new BlueBox()); blueBox.x = 2048 / 2; blueBox.y = 2732 / 5; } };
===================================================================
--- original.js
+++ change.js
@@ -33,16 +33,30 @@
blueBox.destroy();
var snow = game.addChild(new Snow());
snow.x = self.x;
snow.y = self.y;
+ var redBox = game.addChild(new RedBox());
+ redBox.x = Math.random() * 2048;
+ redBox.y = 2732;
}
if (self.intersects(button)) {
var yellowBox = game.addChild(new YellowBox());
yellowBox.x = blueBox.x;
yellowBox.y = blueBox.y;
}
};
});
+var RedBox = Container.expand(function () {
+ var self = Container.call(this);
+ var redBoxGraphics = self.attachAsset('redBox', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -5;
+ self.update = function () {
+ self.y += self.speed;
+ };
+});
var Snow = Container.expand(function () {
var self = Container.call(this);
var snowGraphics = self.attachAsset('snow', {
anchorX: 0.5,
@@ -83,8 +97,20 @@
glider.x = x;
glider.y = y;
};
game.update = function () {
+ game.update = function () {
+ if (!blueBox || blueBox.destroyed) {
+ blueBox = game.addChild(new BlueBox());
+ blueBox.x = 2048 / 2;
+ blueBox.y = 2732 / 5;
+ }
+ for (var i = game.children.length - 1; i >= 0; i--) {
+ if (game.children[i] instanceof RedBox && game.children[i].y < 0) {
+ game.children[i].destroy();
+ }
+ }
+ };
if (!blueBox || blueBox.destroyed) {
blueBox = game.addChild(new BlueBox());
blueBox.x = 2048 / 2;
blueBox.y = 2732 / 5;
human. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
classical style
flower. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
little flower. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
older
side face
halo. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.