User prompt
make it smaller and under the score
User prompt
make an hi-score
User prompt
bigger
User prompt
make the score bigger
User prompt
change the button to a different color every time it is clicked
User prompt
make a sound when the button clicked
User prompt
make the cursor button swing
User prompt
make a background
User prompt
set font to .VnAvant
User prompt
make the foont bald
User prompt
make the font bold
User prompt
Change the font of the score text to 'Calibri'
User prompt
set font to time new roman
User prompt
add a cursor button
Initial prompt
Click
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Define a simple Button class that will be used for the tap target var Button = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Add a swinging animation to the button self.rotation = Math.sin(LK.ticks / 10) / 10; }; // Add a cursor to the button self.cursor = 'pointer'; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize score and score text var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff", font: "'.VnAvant', serif", fontWeight: 'bold' }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create the button and position it at the center of the screen var background = game.addChild(LK.getAsset('background', { anchorX: 0, anchorY: 0 })); var button = game.addChild(new Button()); button.x = 2048 / 2; button.y = 2732 / 2; // Update score function function updateScore() { score += 1; scoreTxt.setText(score); } // Handle button press button.down = function (x, y, obj) { updateScore(); // Change the color of the button every time it is clicked var colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff]; var randomColor = colors[Math.floor(Math.random() * colors.length)]; button.tint = randomColor; // Play a sound when the button is clicked LK.getSound('clicksound').play(); }; // Game update function game.update = function () { // No specific update logic for the game };
===================================================================
--- original.js
+++ change.js
@@ -52,10 +52,12 @@
}
// Handle button press
button.down = function (x, y, obj) {
updateScore();
- // Flash the button to give feedback
- LK.effects.flashObject(button, 0xff0000, 100);
+ // Change the color of the button every time it is clicked
+ var colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff];
+ var randomColor = colors[Math.floor(Math.random() * colors.length)];
+ button.tint = randomColor;
// Play a sound when the button is clicked
LK.getSound('clicksound').play();
};
// Game update function