var ColorButton = Container.expand(function (color) { var self = Container.call(this); var buttonGraphics = self.createAsset('colorButton' + color, 'Color Button ' + color, .5, .5); if (color === 'blu') buttonGraphics.destroy(); if (color === 'red') buttonGraphics.destroy(); if (color === 'yellow') buttonGraphics.destroy(); if (color === 'green') buttonGraphics.destroy(); self.color = color; }); 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 (color) { 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(); } }); });
var ColorButton = Container.expand(function (color) {
var self = Container.call(this);
var buttonGraphics = self.createAsset('colorButton' + color, 'Color Button ' + color, .5, .5);
if (color === 'blu') buttonGraphics.destroy();
if (color === 'red') buttonGraphics.destroy();
if (color === 'yellow') buttonGraphics.destroy();
if (color === 'green') buttonGraphics.destroy();
self.color = color;
});
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 (color) {
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();
}
});
});