/**** * Classes ****/ // Block class var Block = Container.expand(function () { var self = Container.call(this); var blockGraphics = self.attachAsset('block', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Block logic goes here }; }); // The assets will be automatically created and loaded by the LK engine // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Player movement logic goes here }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ // Initialize player and blocks var player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 / 2; var blocks = []; for (var i = 0; i < 10; i++) { for (var j = 0; j < 10; j++) { var block = game.addChild(new Block()); block.x = i * 200; block.y = j * 200; blocks.push(block); } } // Game update function game.update = function () { // Game logic goes here }; // Touch events game.down = function (x, y, obj) { // Touch down logic goes here }; game.move = function (x, y, obj) { // Touch move logic goes here }; game.up = function (x, y, obj) { // Touch up logic goes here };
/****
* Classes
****/
// Block class
var Block = Container.expand(function () {
var self = Container.call(this);
var blockGraphics = self.attachAsset('block', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Block logic goes here
};
});
// The assets will be automatically created and loaded by the LK engine
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Player movement logic goes here
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
// Initialize player and blocks
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 / 2;
var blocks = [];
for (var i = 0; i < 10; i++) {
for (var j = 0; j < 10; j++) {
var block = game.addChild(new Block());
block.x = i * 200;
block.y = j * 200;
blocks.push(block);
}
}
// Game update function
game.update = function () {
// Game logic goes here
};
// Touch events
game.down = function (x, y, obj) {
// Touch down logic goes here
};
game.move = function (x, y, obj) {
// Touch move logic goes here
};
game.up = function (x, y, obj) {
// Touch up logic goes here
};