/****
* Initialize Game
****/
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
//<Write entity 'classes' with empty functions for important behavior here>
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize score and score display
var score = 0;
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Function to update score
function updateScore() {
score += 1;
scoreTxt.setText(score);
}
// Handle tap events on the game
game.down = function (x, y, obj) {
updateScore();
};
// Center the score text horizontally
scoreTxt.x = 2048 / 2;
scoreTxt.y = 100;
// Create a button
var button = LK.getAsset('button', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 - 100,
scaleX: 2,
scaleY: 2
});
game.addChild(button);
// Handle button press
button.down = function (x, y, obj) {
updateScore();
};
// Update function called every frame
game.update = function () {
// Game logic that needs to be updated every frame
}; ===================================================================
--- original.js
+++ change.js
@@ -35,9 +35,11 @@
var button = LK.getAsset('button', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
- y: 2732 - 100
+ y: 2732 - 100,
+ scaleX: 2,
+ scaleY: 2
});
game.addChild(button);
// Handle button press
button.down = function (x, y, obj) {