User prompt
Please fix the bug: 'livesDisplay.setText is not a function' in or related to this line: 'livesDisplay.setText('Lives: ' + playerLives);' Line Number: 58
User prompt
the player has 3 lives,
User prompt
increase the size of the bg asset I meant this. do
User prompt
put bg in full screen, 720p
User prompt
make it so that when you touch the screen, the pencil is thrown down.
User prompt
make the pencil move left and right
User prompt
It's a fucking position, do it now
User prompt
Add pencil
User prompt
Remove all code
User prompt
Remove all in scene
Initial prompt
Fruit pencil
/**** * Classes ****/ var Pencil = Container.expand(function () { var self = Container.call(this); // Attach the pencil image asset to the container var pencilGraphics = self.attachAsset('Pencil', { anchorX: 0.5, anchorY: 0.5 }); // Set initial position of the pencil self.x = 1024; // Center horizontally self.y = 0; // Position at the top of the screen // Add update method to move the pencil left and right self.update = function () { // Move pencil left and right if (self.x <= 0 || self.x >= 2048) { self.speed = -self.speed; // Reverse direction when hitting screen edges } self.x += self.speed; }; self.speed = 5; // Initial speed of the pencil }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Initialize player lives var playerLives = 3; // Display player lives on the screen var livesDisplay = LK.getAsset('Life', { anchorX: 0.5, anchorY: 0.5, x: 100, // Position on the left side of the screen y: 100 // Position near the top of the screen }); game.addChild(livesDisplay); // Function to update lives display function updateLivesDisplay() { // Update the display based on the number of lives livesDisplay.setText('Lives: ' + playerLives); } // Call updateLivesDisplay initially to show the starting lives updateLivesDisplay(); var bg = LK.getAsset('Bg', { anchorX: 0.5, anchorY: 0.5, scaleX: 2048 / 100, // Scale to fit the screen width scaleY: 2732 / 100, // Scale to fit the screen height // Scale to fit 720p height x: 2048 / 2, // Center horizontally y: 2732 / 2 // Center vertically }); game.addChild(bg); var pencil = game.addChild(new Pencil()); // Add event listener for screen touch to throw the pencil down game.down = function (x, y, obj) { pencil.speed = 20; // Set a downward speed for the pencil pencil.update = function () { // Move pencil down pencil.y += pencil.speed; }; }; // Ensure the game updates the pencil's position every tick game.update = function () { pencil.update(); // Check if the pencil has missed the target (e.g., gone off-screen) if (pencil.y > 2732) { playerLives--; // Decrease player lives updateLivesDisplay(); // Update the lives display // Check if the player has no more lives if (playerLives <= 0) { LK.showGameOver(); // Show game over screen } else { // Reset pencil position if lives are remaining pencil.y = 0; pencil.speed = 5; // Reset speed } } };
===================================================================
--- original.js
+++ change.js
@@ -31,8 +31,26 @@
/****
* Game Code
****/
+// Initialize player lives
+var playerLives = 3;
+// Display player lives on the screen
+var livesDisplay = LK.getAsset('Life', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 100,
+ // Position on the left side of the screen
+ y: 100 // Position near the top of the screen
+});
+game.addChild(livesDisplay);
+// Function to update lives display
+function updateLivesDisplay() {
+ // Update the display based on the number of lives
+ livesDisplay.setText('Lives: ' + playerLives);
+}
+// Call updateLivesDisplay initially to show the starting lives
+updateLivesDisplay();
var bg = LK.getAsset('Bg', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2048 / 100,
@@ -56,5 +74,18 @@
};
// Ensure the game updates the pencil's position every tick
game.update = function () {
pencil.update();
+ // Check if the pencil has missed the target (e.g., gone off-screen)
+ if (pencil.y > 2732) {
+ playerLives--; // Decrease player lives
+ updateLivesDisplay(); // Update the lives display
+ // Check if the player has no more lives
+ if (playerLives <= 0) {
+ LK.showGameOver(); // Show game over screen
+ } else {
+ // Reset pencil position if lives are remaining
+ pencil.y = 0;
+ pencil.speed = 5; // Reset speed
+ }
+ }
};
\ No newline at end of file
Pencil. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
picnic bg. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
heart icon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
mango fruit with eye and mouth animation.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Banana with eye and mouth animation.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
picnic bg in a night sky. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Watermelon with eye and mouth animation. In-Game asset. 2d. High contrast. No shadows
Orange with eye and mouth animation. In-Game asset. 2d. High contrast. No shadows
Shop icon. In-Game asset. 2d. High contrast. No shadows
Coin icon. In-Game asset. 2d. High contrast. No shadows
Emoji_shocked. In-Game asset. 2d. High contrast. No shadows
Settings icon. In-Game asset. 2d. High contrast. No shadows