var Pencil = Container.expand(function () { var self = Container.call(this); var pencilGraphics = self.createAsset('pencil', 'Pencil for drawing', .5, .5); self.speed = 5; self.move = function () { self.x += self.speed; }; }); var Drawing = Container.expand(function () { var self = Container.call(this); var drawingGraphics = self.createAsset('drawing', 'Drawing by pencil', .5, .5); }); var Game = Container.expand(function () { var self = Container.call(this); var pencil = self.addChild(new Pencil()); pencil.x = 1024; pencil.y = 1366; var drawings = []; var isDrawing = false; var resetButton = self.createAsset('resetButton', 'Reset Button', 0, 0); resetButton.x = 0; resetButton.y = 0; LK.gui.topLeft.addChild(resetButton); resetButton.on('down', function () { LK.showGameOver(); }); var timer = LK.setInterval(function () { if (isDrawing) { var newDrawing = new Drawing(); newDrawing.x = pencil.x; newDrawing.y = pencil.y; drawings.push(newDrawing); self.addChild(newDrawing); } }, 1000 / 60); pencil.on('down', function (obj) { isDrawing = true; }); stage.on('up', function (obj) { isDrawing = false; }); stage.on('move', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); pencil.x = pos.x; pencil.y = pos.y; }); LK.on('tick', function () { pencil.move(); if (pencil.x < 0 || pencil.x > 2048 || pencil.y < 0 || pencil.y > 2732) { LK.clearInterval(timer); LK.showGameOver(); } }); });
===================================================================
--- original.js
+++ change.js
@@ -16,12 +16,12 @@
pencil.x = 1024;
pencil.y = 1366;
var drawings = [];
var isDrawing = false;
- var resetButton = self.createAsset('resetButton', 'Reset Button', 1, 0);
- resetButton.x = 2048;
+ var resetButton = self.createAsset('resetButton', 'Reset Button', 0, 0);
+ resetButton.x = 0;
resetButton.y = 0;
- LK.gui.topRight.addChild(resetButton);
+ LK.gui.topLeft.addChild(resetButton);
resetButton.on('down', function () {
LK.showGameOver();
});
var timer = LK.setInterval(function () {