/**** * Classes ****/ var Toy = Container.expand(function () { var self = Container.call(this); var toyGraphics = self.attachAsset('puppyToy', { anchorX: 0.5, anchorY: 0.5 }); self.reset = function () { self.x = Math.random() < 0.5 ? 512 : 2048 - 512; // Left or right side of the screen self.y = Math.random() * (2732 / 3 * 2 - 64) + 2732 / 3 + 32; // Fixed position in the bottom 2/3 of the screen }; self.on('down', function () { self.reset(); // Reset toy position when tapped LK.setScore(LK.getScore() + 1); // Increase score scoreTxt.setText(LK.getScore()); // Update score display }); self.reset(); // Initialize toy position }); var Puppy = Container.expand(function () { var self = Container.call(this); var puppyGraphic = self.attachAsset('puppyHappy', { anchorX: 0.5, anchorY: 0.5 }); self.x = 2048 / 2; self.y = 2732 / 4; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Light blue background to represent the sky }); /**** * Game Code ****/ var puppy = game.addChild(new Puppy()); var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); scoreTxt.x = 2048 / 2; scoreTxt.y = 125.37; // Position score text below the puppyHappyGraphic LK.gui.top.addChild(scoreTxt); var toys = []; for (var i = 0; i < 5; i++) { var toy = new Toy(); toys.push(toy); game.addChild(toy); } LK.on('tick', function () { // Game logic to be executed each frame // In this simple game, toys are static and only need to be reset when tapped }); // No need for additional event listeners as the toys handle their own 'down' events
===================================================================
--- original.js
+++ change.js
@@ -8,9 +8,9 @@
anchorY: 0.5
});
self.reset = function () {
self.x = Math.random() < 0.5 ? 512 : 2048 - 512; // Left or right side of the screen
- self.y = Math.random() * (2732 - 64) + 32; // Random position within the screen height
+ self.y = Math.random() * (2732 / 3 * 2 - 64) + 2732 / 3 + 32; // Fixed position in the bottom 2/3 of the screen
};
self.on('down', function () {
self.reset(); // Reset toy position when tapped
LK.setScore(LK.getScore() + 1); // Increase score
@@ -23,10 +23,10 @@
var puppyGraphic = self.attachAsset('puppyHappy', {
anchorX: 0.5,
anchorY: 0.5
});
- self.x = 2048 / 4;
- self.y = 2732 / 2;
+ self.x = 2048 / 2;
+ self.y = 2732 / 4;
});
/****
* Initialize Game
A happy golder retriever puppy. tongue hanging out in happiness. sitting down and looking at the viewer.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
sad golden retriever puppy. Single Game Texture. In-Game asset. 2d.
a sad crying golden retriever puppy. lying down. face on front paws. looking at viewer.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute looking dog toy shaped like a bone.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute looking dog toy shaped like a bone.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute looking dog toy shaped like a bone.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cartoon bug. evil looking. red and brown color.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cartoon bug. evil looking. dark blue and red color.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cartoon skeleton puppy. lying down. head between paws.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.