Code edit (1 edits merged)
Please save this source code
User prompt
lanes should be respectively at 1024-200-3 and 1024+200+3
User prompt
make lanes closer to center
User prompt
don't spawn 2 consecutives tiles on the same lane
User prompt
use column asset to separete lanes
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: tile.containsPoint is not a function' in or related to this line: 'if (tile.containsPoint({' Line Number: 86
Initial prompt
Piano Test
/**** * Classes ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Define a class for the PianoTile var PianoTile = Container.expand(function () { var self = Container.call(this); // Create and attach a black rectangle as the tile var tileGraphics = self.attachAsset('tile', { anchorX: 0.5, anchorY: 0.5 }); // Set the speed of the tile self.speed = 5; // Update function to move the tile downwards self.update = function () { self.y += self.speed; }; // Function to handle tap on the tile self.tap = function () { // Increase score and destroy the tile LK.setScore(LK.getScore() + 1); self.destroy(); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x4169e1 //Init game with black background }); /**** * Game Code ****/ // Initialize score display var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Array to keep track of active tiles var tiles = []; // Function to create a new tile function createTile() { var newTile = new PianoTile(); // Randomly position the tile in one of the two lanes newTile.x = Math.random() > 0.5 ? 512 : 1536; newTile.y = -100; // Start above the screen tiles.push(newTile); game.addChild(newTile); } // Game update function game.update = function () { // Update score display scoreTxt.setText(LK.getScore()); // Create a new tile every 60 ticks if (LK.ticks % 60 == 0) { createTile(); } // Update and check each tile for (var i = tiles.length - 1; i >= 0; i--) { var tile = tiles[i]; tile.update(); // Check if tile is off-screen if (tile.y > 2732) { // End game if a tile is missed LK.showGameOver(); return; } } }; // Handle tap events game.down = function (x, y, obj) { // Check if a tile was tapped for (var i = tiles.length - 1; i >= 0; i--) { var tile = tiles[i]; if (tile.intersects({ x: x, y: y, width: 1, height: 1 })) { tile.tap(); tiles.splice(i, 1); break; } } };
===================================================================
--- original.js
+++ change.js
@@ -28,9 +28,9 @@
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x4169e1 //Init game with black background
});
/****
* Game Code