User prompt
Please fix the bug: 'Uncaught ReferenceError: tween is not defined' in or related to this line: 'tween(startBtn, {' Line Number: 511 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Sen yap
User prompt
Sen düzelt
User prompt
Eklentiler yüklenmedi hatası veriyor
User prompt
Hatayı düzelt
User prompt
Assestleri feri getir
User prompt
Aseste de sil
User prompt
Pause butonunu sil
User prompt
Kalpler gözükmüyor
User prompt
Can shn3 üst tarfta gözüksün 3 kalp olarak
User prompt
Oyuna can ekle üç canımız olsun
User prompt
%20 yerine %3 olsun
User prompt
Her 10 saniyede bir meyve düşme hızı %20 artsın
User prompt
Meyveler aşağı inerken yavaş yavaş etrafında dönsün animasyonu ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add background shn3
User prompt
Meyve toplayınca ses çalsın ve bunu sound asseste ekle
User prompt
Pause kaldır ve oyunda olmayan tüm assestleri sil
User prompt
Pause basınca ekranda üç buton çıksın
User prompt
Butonlar gözükmüyor bunu düzelt ve aseste ekle
User prompt
Tekrar söylüyorum pause butonuna basınca üç buton gözüksün ilk buton oyuna devam etsin ikincisi de settingse atsın üçüncü de başlangıca atsın
User prompt
Butonlar gözükmüyor
User prompt
Pause button basınca herşey dursun ve üç buton gözüksün ilki devam ettirme ikincisi shn2 ye atsın üçüncü de shn1 e atsın bunlar sadece buton olsun ve asseste ekle
User prompt
Pause butonuna basınca herşey dursun ve 3 buton gözüksün ilki devam etsin ama sadece buton olsun ikincisi shn2 ye atsın üçüncü de shn1 e atsın
User prompt
shn3 üst butona pause adı verelim
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Fruit class: represents a collectible fruit var Fruit = Container.expand(function () { var self = Container.call(this); // Randomly pick a fruit image asset for variety var fruitAssets = ['fruit', 'fruit2', 'fruit3', 'fruit4']; var fruitAssetId = fruitAssets[Math.floor(Math.random() * fruitAssets.length)]; // Optionally, randomize color for extra variety (if you want to tint, but not required) // var fruitColors = [0xff3b3b, 0xffe14d, 0x4de14d, 0x4db8ff, 0xff7ff0]; // var color = fruitColors[Math.floor(Math.random() * fruitColors.length)]; // Create fruit image asset var fruitAsset = self.attachAsset(fruitAssetId, { width: 120, height: 120, anchorX: 0.5, anchorY: 0.5 }); // Used for animation self.alpha = 0; self.scaleX = 0.7; self.scaleY = 0.7; // Animate fruit appearing tween(self, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.easeOut }); // For tracking if already collected self.collected = false; // Destroy with a pop animation self.collect = function (_onFinish) { if (self.collected) return; self.collected = true; tween(self, { scaleX: 1.4, scaleY: 1.4, alpha: 0 }, { duration: 180, easing: tween.easeIn, onFinish: function onFinish() { self.destroy(); if (_onFinish) _onFinish(); } }); }; return self; }); // Player class: basket image, centered anchor var Player = Container.expand(function () { var self = Container.call(this); // Use basket image asset, centered anchor var basketAsset = self.attachAsset('basket', { anchorX: 0.5, anchorY: 0.5 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xf7f7f7 }); /**** * Game Code ****/ // shn1 // shn2 // Devam Et // semi-transparent bg // Scene naming var SCENE_START = "shn1"; var SCENE_SETTINGS = "shn2"; var SCENE_GAME = "shn3"; // Second block above start, can use same asset or a new one if desired // Tween plugin for fruit spawn/collect animations // Game constants // Pause menu round buttons as assets var GAME_WIDTH = 2048; var GAME_HEIGHT = 2732; var FRUIT_SPAWN_MIN = 900; // ms var FRUIT_SPAWN_MAX = 1800; // ms var FRUIT_LIFETIME = 2600; // ms before fruit disappears var WIN_SCORE = 20; var FRUIT_FALL_SPEED = 10; // Meyve hızı 10 // Game state var fruits = []; var player = null; var dragNode = null; var score = 0; var scoreTxt = null; var spawnTimer = null; var fruitSpawnInterval = FRUIT_SPAWN_MAX; var lastTouch = { x: GAME_WIDTH / 2, y: GAME_HEIGHT * 0.8 }; // Set up background color game.setBackgroundColor(0xf7f7f7); // --- START SCREEN OVERLAY --- var startOverlay = new Container(); startOverlay.width = GAME_WIDTH; startOverlay.height = GAME_HEIGHT; startOverlay.interactive = true; // Start screen background image var startBg = LK.getAsset('startBg', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: GAME_WIDTH, height: GAME_HEIGHT }); startOverlay.addChild(startBg); // Semi-transparent background (over the image, for darkening effect) var overlayBg = LK.getAsset('player', { width: GAME_WIDTH, height: GAME_HEIGHT, color: 0x000000, shape: 'box', anchorX: 0, anchorY: 0, x: 0, y: 0 }); overlayBg.alpha = 0.3; startOverlay.addChild(overlayBg); // Add a new block at the very top of the start screen var startTopBlock2 = LK.getAsset('startTopBlock', { anchorX: 0.5, anchorY: 0, x: GAME_WIDTH / 2, y: 80 // higher than the first block // Use asset's native size, do not scale or stretch }); startOverlay.addChild(startTopBlock2); // Add a new block at the top of the start screen var startTopBlock = LK.getAsset('startTopBlock', { anchorX: 0.5, anchorY: 0, x: GAME_WIDTH / 2, y: 200 // Use asset's native size, do not scale or stretch }); startOverlay.addChild(startTopBlock); // "Başla" button (centered) - now as a dedicated asset, no text or title var startBtn = LK.getAsset('startBtn', { anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH / 2, y: GAME_HEIGHT / 2 }); startOverlay.addChild(startBtn); // Settings button (even further below start button, centered) var settingsBtn = LK.getAsset('settingsBtn', { anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH / 2, y: GAME_HEIGHT / 2 + 420 // moved up, now 420px below startBtn }); startOverlay.addChild(settingsBtn); // Settings menu overlay (hidden by default, shown as a separate "scene" when settings is pressed) var settingsMenuOverlay = new Container(); settingsMenuOverlay.width = GAME_WIDTH; settingsMenuOverlay.height = GAME_HEIGHT; settingsMenuOverlay.visible = false; settingsMenuOverlay.interactive = true; var currentScene = SCENE_START; // Full screen background image for settings menu var settingsMenuBgImage = LK.getAsset('settingsMenuBg', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: GAME_WIDTH, height: GAME_HEIGHT }); settingsMenuOverlay.addChild(settingsMenuBgImage); // Semi-transparent overlay for settings menu (for click-to-close) var settingsMenuBg = LK.getAsset('player', { width: GAME_WIDTH, height: GAME_HEIGHT, color: 0x000000, shape: 'box', anchorX: 0, anchorY: 0, x: 0, y: 0 }); settingsMenuBg.alpha = 0.2; settingsMenuOverlay.addChild(settingsMenuBg); // Settings menu buttons (centered vertically: top, center, bottom) var menuBtnSpacing = 340; var menuBtnYCenter = GAME_HEIGHT / 2; var menuBtn1 = LK.getAsset('settingsMenuBtn1', { anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH / 2, y: menuBtnYCenter - menuBtnSpacing }); var menuBtn2 = LK.getAsset('settingsMenuBtn2', { anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH / 2, y: menuBtnYCenter }); var menuBtn3 = LK.getAsset('settingsMenuBtn3', { anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH / 2, y: menuBtnYCenter + menuBtnSpacing }); settingsMenuOverlay.addChild(menuBtn1); settingsMenuOverlay.addChild(menuBtn2); settingsMenuOverlay.addChild(menuBtn3); // Hide settings menu when background is pressed settingsMenuBg.down = function (x, y, obj) { settingsMenuOverlay.visible = false; startOverlay.visible = true; currentScene = SCENE_START; }; // Close menu on any menu button press menuBtn1.down = function (x, y, obj) { // Hide settings and start overlays settingsMenuOverlay.visible = false; if (startOverlay.parent) startOverlay.parent.removeChild(startOverlay); currentScene = SCENE_GAME; // Start the game if not already started if (!gameStarted) { gameStarted = true; showGameElements(); scheduleNextFruit(); } else { showGameElements(); } // Show move buttons directly leftBtn.visible = true; rightBtn.visible = true; moveButtonsVisible = true; }; menuBtn2.down = function (x, y, obj) { settingsMenuOverlay.visible = false; startOverlay.visible = true; currentScene = SCENE_START; }; menuBtn3.down = function (x, y, obj) { settingsMenuOverlay.visible = false; startOverlay.visible = true; currentScene = SCENE_START; }; game.addChild(settingsMenuOverlay); game.addChild(startOverlay); // Show settings menu as a separate "scene" when settingsBtn is pressed settingsBtn.down = function (x, y, obj) { // Animate settingsBtn shrinking tween(settingsBtn, { scaleX: 0.85, scaleY: 0.85 }, { duration: 90, easing: tween.cubicIn, onFinish: function onFinish() { tween(settingsBtn, { scaleX: 0.1, scaleY: 0.1, alpha: 0 }, { duration: 180, easing: tween.cubicIn, onFinish: function onFinish() { // After animation, show settings menu settingsMenuOverlay.visible = true; startOverlay.visible = false; currentScene = SCENE_SETTINGS; // Hide move buttons when not in game leftBtn.visible = false; rightBtn.visible = false; moveButtonsVisible = false; // Reset settingsBtn for next time settingsBtn.scaleX = 1; settingsBtn.scaleY = 1; settingsBtn.alpha = 1; } }); } }); }; // --- GAME ELEMENTS (hidden until start) --- // Add shn3TopBtn to top center in shn3 (game) scene var shn3TopBtn = LK.getAsset('shn3TopBtn', { anchorX: 0.5, anchorY: 0, x: GAME_WIDTH / 2, y: 100 // below top safe area }); // Add 'Pause' text label to the button var shn3TopBtnLabel = new Text2('Pause', { size: 90, fill: "#fff" }); shn3TopBtnLabel.anchor.set(0.5, 0.5); shn3TopBtnLabel.x = shn3TopBtn.width / 2; shn3TopBtnLabel.y = shn3TopBtn.height / 2; shn3TopBtn.addChild(shn3TopBtnLabel); shn3TopBtn.visible = false; game.addChild(shn3TopBtn); // Pause button logic shn3TopBtn.down = function (x, y, obj) { if (!pauseOverlay.visible) { // Pause game logic pauseOverlay.visible = true; pauseMenuBtn1.visible = true; pauseMenuBtn2.visible = true; pauseMenuBtn3.visible = true; hideGameElements(); } }; // --- PAUSE OVERLAY & BUTTONS --- var pauseOverlay = new Container(); pauseOverlay.width = GAME_WIDTH; pauseOverlay.height = GAME_HEIGHT; pauseOverlay.visible = false; pauseOverlay.interactive = true; // Background (semi-transparent) var pauseOverlayBg = LK.getAsset('pauseOverlayBg', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: GAME_WIDTH, height: GAME_HEIGHT }); pauseOverlayBg.alpha = 0.45; pauseOverlay.addChild(pauseOverlayBg); // Pause menu buttons (centered vertically) var pauseBtnSpacing = 260; var pauseBtnYCenter = GAME_HEIGHT / 2; // Devam Et (Resume) button var pauseMenuBtn1 = LK.getAsset('pauseMenuBtn1', { anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH / 2, y: pauseBtnYCenter - pauseBtnSpacing }); var pauseMenuBtn1Label = new Text2('Devam Et', { size: 90, fill: "#222" }); pauseMenuBtn1Label.anchor.set(0.5, 0.5); pauseMenuBtn1Label.x = pauseMenuBtn1.width / 2; pauseMenuBtn1Label.y = pauseMenuBtn1.height / 2; pauseMenuBtn1.addChild(pauseMenuBtn1Label); // shn2 button var pauseMenuBtn2 = LK.getAsset('pauseMenuBtn2', { anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH / 2, y: pauseBtnYCenter }); var pauseMenuBtn2Label = new Text2('shn2', { size: 90, fill: "#222" }); pauseMenuBtn2Label.anchor.set(0.5, 0.5); pauseMenuBtn2Label.x = pauseMenuBtn2.width / 2; pauseMenuBtn2Label.y = pauseMenuBtn2.height / 2; pauseMenuBtn2.addChild(pauseMenuBtn2Label); // shn1 button var pauseMenuBtn3 = LK.getAsset('pauseMenuBtn3', { anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH / 2, y: pauseBtnYCenter + pauseBtnSpacing }); var pauseMenuBtn3Label = new Text2('shn1', { size: 90, fill: "#222" }); pauseMenuBtn3Label.anchor.set(0.5, 0.5); pauseMenuBtn3Label.x = pauseMenuBtn3.width / 2; pauseMenuBtn3Label.y = pauseMenuBtn3.height / 2; pauseMenuBtn3.addChild(pauseMenuBtn3Label); pauseOverlay.addChild(pauseMenuBtn1); pauseOverlay.addChild(pauseMenuBtn2); pauseOverlay.addChild(pauseMenuBtn3); // Add pauseOverlay as the last child so it is above all game elements player = new Player(); player.x = GAME_WIDTH / 2; player.y = GAME_HEIGHT * 0.8; player.visible = false; game.addChild(player); scoreTxt = new Text2('0', { size: 120, fill: 0x222222 }); scoreTxt.anchor.set(0.5, 0); scoreTxt.visible = false; LK.gui.top.addChild(scoreTxt); game.addChild(pauseOverlay); // Ensure pauseOverlay is above all game elements // Pause menu button logic pauseMenuBtn1.down = function (x, y, obj) { // Devam Et (Resume) pauseOverlay.visible = false; pauseMenuBtn1.visible = false; pauseMenuBtn2.visible = false; pauseMenuBtn3.visible = false; showGameElements(); }; pauseMenuBtn2.down = function (x, y, obj) { // Go to shn2 (settings) pauseOverlay.visible = false; pauseMenuBtn1.visible = false; pauseMenuBtn2.visible = false; pauseMenuBtn3.visible = false; settingsMenuOverlay.visible = true; startOverlay.visible = false; currentScene = SCENE_SETTINGS; }; pauseMenuBtn3.down = function (x, y, obj) { // Go to shn1 (start) pauseOverlay.visible = false; pauseMenuBtn1.visible = false; pauseMenuBtn2.visible = false; pauseMenuBtn3.visible = false; settingsMenuOverlay.visible = false; startOverlay.visible = true; currentScene = SCENE_START; hideGameElements(); }; // --- Add left/right move buttons, initially hidden, and a toggle button at top right --- // Button sizes and positions are optimized for mobile (large touch targets, no overlap with menu) var buttonSize = 260; var buttonMargin = 120; var buttonY = GAME_HEIGHT - buttonSize - 60; // Toggle button (top right, avoid top left 100x100 and right edge) var toggleBtnSize = 120; var toggleBtn = LK.getAsset('player', { width: toggleBtnSize, height: toggleBtnSize, color: 0x222222, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH - 100 - toggleBtnSize / 2 - 20, // right margin, avoid top right 100x100 y: 100 / 2 + 20 }); var toggleIcon = new Text2('☰', { size: 80, fill: "#fff" }); toggleIcon.anchor.set(0.5, 0.5); toggleIcon.x = toggleBtn.width / 2; toggleIcon.y = toggleBtn.height / 2; toggleBtn.addChild(toggleIcon); toggleBtn.visible = false; game.addChild(toggleBtn); // Left button (bottom left, above safe margin) var leftBtn = LK.getAsset('player', { width: buttonSize, height: buttonSize, color: 0x3b7fff, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: buttonMargin + buttonSize / 2, y: buttonY }); var leftArrow = new Text2('◀', { size: 180, fill: "#fff" }); leftArrow.anchor.set(0.5, 0.5); leftArrow.x = leftBtn.width / 2; leftArrow.y = leftBtn.height / 2; leftBtn.addChild(leftArrow); leftBtn.visible = false; // Right button (bottom right, above safe margin) var rightBtn = LK.getAsset('player', { width: buttonSize, height: buttonSize, color: 0x3b7fff, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH - buttonMargin - buttonSize / 2, y: buttonY }); var rightArrow = new Text2('▶', { size: 180, fill: "#fff" }); rightArrow.anchor.set(0.5, 0.5); rightArrow.x = rightBtn.width / 2; rightArrow.y = rightBtn.height / 2; rightBtn.addChild(rightArrow); rightBtn.visible = false; game.addChild(leftBtn); game.addChild(rightBtn); // Toggle logic var moveButtonsVisible = false; toggleBtn.down = function (x, y, obj) { moveButtonsVisible = !moveButtonsVisible; leftBtn.visible = moveButtonsVisible; rightBtn.visible = moveButtonsVisible; }; // --- START BUTTON LOGIC --- function showGameElements() { player.visible = true; scoreTxt.visible = true; toggleBtn.visible = true; shn3TopBtn.visible = true; pauseOverlay.visible = false; // Hide pause overlay if visible pauseMenuBtn1.visible = false; pauseMenuBtn2.visible = false; pauseMenuBtn3.visible = false; // Move buttons are only visible if toggled, but always hidden at game start leftBtn.visible = false; rightBtn.visible = false; moveButtonsVisible = false; } function hideGameElements() { player.visible = false; scoreTxt.visible = false; toggleBtn.visible = false; shn3TopBtn.visible = false; leftBtn.visible = false; rightBtn.visible = false; moveButtonsVisible = false; pauseOverlay.visible = false; // Hide pause overlay if visible pauseMenuBtn1.visible = false; pauseMenuBtn2.visible = false; pauseMenuBtn3.visible = false; } // When start is pressed, remove overlay and show game elements, start fruit spawning var gameStarted = false; startBtn.down = function (x, y, obj) { if (gameStarted) return; gameStarted = true; currentScene = SCENE_GAME; // Animate startBtn shrinking tween(startBtn, { scaleX: 0.85, scaleY: 0.85 }, { duration: 90, easing: tween.cubicIn, onFinish: function onFinish() { tween(startBtn, { scaleX: 0.1, scaleY: 0.1, alpha: 0 }, { duration: 180, easing: tween.cubicIn, onFinish: function onFinish() { // Animate startTopBlock as before tween(startTopBlock, { scaleX: 0.1, scaleY: 0.1, alpha: 0 }, { duration: 220, easing: tween.cubicIn, onFinish: function onFinish() { if (startOverlay.parent) startOverlay.parent.removeChild(startOverlay); showGameElements(); scheduleNextFruit(); } }); } }); } }); }; hideGameElements(); // Button press logic var moveBtnInterval = null; // Pürüzsüz hareket için hız ve hedef yön var MOVE_SPEED = 32; // px/frame, pürüzsüz hız (20'den biraz daha hızlı, ayarlanabilir) var playerVelocity = 0; var playerTargetDir = 0; // -1: sola, 1: sağa, 0: dur // Sepet hızlandırma için çarpan (her 50'de %5 artar) var playerSpeedMultiplier = 1; var lastSpeedupScore = 0; // Touch/hold left leftBtn.down = function (x, y, obj) { if (!leftBtn.visible) return; playerTargetDir = -1; }; leftBtn.up = function (x, y, obj) { if (playerTargetDir === -1) playerTargetDir = 0; }; // Touch/hold right rightBtn.down = function (x, y, obj) { if (!rightBtn.visible) return; playerTargetDir = 1; }; rightBtn.up = function (x, y, obj) { if (playerTargetDir === 1) playerTargetDir = 0; }; // Helper: update score display function updateScore() { scoreTxt.setText(score); } // Helper: spawn a fruit at a random X position at the top, and make it fall down function spawnFruit() { // Avoid top 100px (menu), and bottom 200px (player area) var margin = 140; var minX = margin; var maxX = GAME_WIDTH - margin; var fruit = new Fruit(); fruit.x = Math.floor(Math.random() * (maxX - minX)) + minX; fruit.y = 120; // Always spawn at the top // All fruits have the same fall speed, controlled by a single variable fruit.fallSpeed = FRUIT_FALL_SPEED; // Track lastY for good practice fruit.lastY = fruit.y; fruits.push(fruit); game.addChild(fruit); // Fruit will only be removed if collected or falls below the screen } // Helper: schedule next fruit spawn, with increasing speed function scheduleNextFruit() { if (!gameStarted) return; // As score increases, spawn interval decreases var minInterval = FRUIT_SPAWN_MIN; var maxInterval = FRUIT_SPAWN_MAX; var progress = Math.min(score / WIN_SCORE, 1); fruitSpawnInterval = maxInterval - (maxInterval - minInterval) * progress; var nextIn = Math.floor(fruitSpawnInterval * (0.7 + Math.random() * 0.6)); // randomize a bit spawnTimer = LK.setTimeout(function () { if (!gameStarted) return; spawnFruit(); scheduleNextFruit(); }, nextIn); } // Dragging logic game.down = function (x, y, obj) { if (!gameStarted) return; // Only start drag if touch is on player (or close to it) var dx = x - player.x; var dy = y - player.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < 120) { dragNode = player; lastTouch.x = x; lastTouch.y = y; // Drag başlarken _targetX'i temizle ki buton hareketiyle çakışmasın player._targetX = undefined; } }; game.move = function (x, y, obj) { if (!gameStarted) return; // Always allow player to follow finger/mouse X (no need to drag on player) // Clamp X to game area var px = Math.max(70, Math.min(GAME_WIDTH - 70, x)); // Instead of tween, set a target and let update loop lerp for ultra-smoothness player._targetX = px; lastTouch.x = px; lastTouch.y = player.y; }; game.up = function (x, y, obj) { if (!gameStarted) return; dragNode = null; // Drag bittiğinde _targetX'i temizle ki tekrar smooth takip başlasın player._targetX = undefined; }; // Main update loop: check for fruit collection game.update = function () { if (!gameStarted) return; // pauseOverlay check removed // FRUIT_FALL_SPEED is now handled by 100s logic above, no need to reset here // Pürüzsüz sepet hareketi // Her +100'de bir %3 hızlandır (örn: 100, 200, 300, ...), ve bunu her zaman uygula if (Math.floor(score / 100) > Math.floor(lastSpeedupScore / 100)) { var speedupSteps = Math.floor(score / 100) - Math.floor(lastSpeedupScore / 100); for (var s = 0; s < speedupSteps; s++) { playerSpeedMultiplier *= 1.03; FRUIT_FALL_SPEED *= 1.03; } lastSpeedupScore = Math.floor(score / 100) * 100; } // Sepet parmak/mouse'u takip ediyorsa ultra-smooth lerp ile hareket etsin if (typeof player._targetX === "number") { // Lerp oranı: 0.22 (daha yüksek = daha hızlı takip, daha düşük = daha yumuşak) player.x += (player._targetX - player.x) * 0.22; // Clamp to game area player.x = Math.max(70, Math.min(GAME_WIDTH - 70, player.x)); lastTouch.x = player.x; lastTouch.y = player.y; } else { // Sadece butonla hareket ediyorsa var moveMultiplier = playerSpeedMultiplier; // Hedef hıza doğru yumuşak geçiş (smooth acceleration) var targetVelocity = playerTargetDir * MOVE_SPEED * moveMultiplier; // Linear interpolation (lerp) ile hız geçişi playerVelocity += (targetVelocity - playerVelocity) * 0.22; // Eğer hedef durmaksa, yavaşça sıfıra yaklaşsın if (playerTargetDir === 0 && Math.abs(playerVelocity) < 1) playerVelocity = 0; var nextX = player.x + playerVelocity; // Clamp to game area nextX = Math.max(70, Math.min(GAME_WIDTH - 70, nextX)); // Only update player.x directly if not dragging (button movement) player.x = nextX; lastTouch.x = player.x; lastTouch.y = player.y; } for (var i = fruits.length - 1; i >= 0; i--) { var fruit = fruits[i]; if (fruit.collected) continue; // Always update fruit fall speed in case it changed (prevents stuck fruits) fruit.fallSpeed = FRUIT_FALL_SPEED; // Move fruit down fruit.lastY = fruit.lastY === undefined ? fruit.y : fruit.lastY; fruit.y += fruit.fallSpeed; // Remove fruit if it falls below the screen (bottom margin) if (fruit.lastY <= GAME_HEIGHT - 120 && fruit.y > GAME_HEIGHT - 120) { if (!fruit.collected) { // Decrease score by 5 if missed score -= 5; if (score < 0) score = 0; updateScore(); // Play pop animation before removing tween(fruit, { scaleX: 1.7, scaleY: 1.7, alpha: 0 }, { duration: 220, easing: tween.cubicIn, onFinish: function onFinish() { fruit.destroy(); } }); // Remove from array for (var j = 0; j < fruits.length; j++) { if (fruits[j] === fruit) { fruits.splice(j, 1); break; } } } // Cancel fruit timeout if (fruit._timeout) LK.clearTimeout(fruit._timeout); continue; } // Check intersection with player if (player.intersects(fruit)) { fruit.collect(function () { // Remove from array for (var j = 0; j < fruits.length; j++) { if (fruits[j] === fruit) { fruits.splice(j, 1); break; } } }); // Cancel fruit timeout if (fruit._timeout) LK.clearTimeout(fruit._timeout); // Add score score += 10; updateScore(); // Win condition removed: no win popup or flash when score reaches WIN_SCORE } fruit.lastY = fruit.y; } }; // On game over or win, cleanup timers game.onDestroy = function () { if (spawnTimer) LK.clearTimeout(spawnTimer); for (var i = 0; i < fruits.length; i++) { if (fruits[i]._timeout) LK.clearTimeout(fruits[i]._timeout); } fruits = []; }; // Initial score updateScore();
===================================================================
--- original.js
+++ change.js
@@ -321,8 +321,11 @@
shn3TopBtn.down = function (x, y, obj) {
if (!pauseOverlay.visible) {
// Pause game logic
pauseOverlay.visible = true;
+ pauseMenuBtn1.visible = true;
+ pauseMenuBtn2.visible = true;
+ pauseMenuBtn3.visible = true;
hideGameElements();
}
};
// --- PAUSE OVERLAY & BUTTONS ---
@@ -392,9 +395,9 @@
pauseMenuBtn3.addChild(pauseMenuBtn3Label);
pauseOverlay.addChild(pauseMenuBtn1);
pauseOverlay.addChild(pauseMenuBtn2);
pauseOverlay.addChild(pauseMenuBtn3);
-game.addChild(pauseOverlay);
+// Add pauseOverlay as the last child so it is above all game elements
player = new Player();
player.x = GAME_WIDTH / 2;
player.y = GAME_HEIGHT * 0.8;
player.visible = false;
@@ -405,24 +408,34 @@
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.visible = false;
LK.gui.top.addChild(scoreTxt);
+game.addChild(pauseOverlay); // Ensure pauseOverlay is above all game elements
// Pause menu button logic
pauseMenuBtn1.down = function (x, y, obj) {
// Devam Et (Resume)
pauseOverlay.visible = false;
+ pauseMenuBtn1.visible = false;
+ pauseMenuBtn2.visible = false;
+ pauseMenuBtn3.visible = false;
showGameElements();
};
pauseMenuBtn2.down = function (x, y, obj) {
// Go to shn2 (settings)
pauseOverlay.visible = false;
+ pauseMenuBtn1.visible = false;
+ pauseMenuBtn2.visible = false;
+ pauseMenuBtn3.visible = false;
settingsMenuOverlay.visible = true;
startOverlay.visible = false;
currentScene = SCENE_SETTINGS;
};
pauseMenuBtn3.down = function (x, y, obj) {
// Go to shn1 (start)
pauseOverlay.visible = false;
+ pauseMenuBtn1.visible = false;
+ pauseMenuBtn2.visible = false;
+ pauseMenuBtn3.visible = false;
settingsMenuOverlay.visible = false;
startOverlay.visible = true;
currentScene = SCENE_START;
hideGameElements();
@@ -510,8 +523,11 @@
scoreTxt.visible = true;
toggleBtn.visible = true;
shn3TopBtn.visible = true;
pauseOverlay.visible = false; // Hide pause overlay if visible
+ pauseMenuBtn1.visible = false;
+ pauseMenuBtn2.visible = false;
+ pauseMenuBtn3.visible = false;
// Move buttons are only visible if toggled, but always hidden at game start
leftBtn.visible = false;
rightBtn.visible = false;
moveButtonsVisible = false;
@@ -524,8 +540,11 @@
leftBtn.visible = false;
rightBtn.visible = false;
moveButtonsVisible = false;
pauseOverlay.visible = false; // Hide pause overlay if visible
+ pauseMenuBtn1.visible = false;
+ pauseMenuBtn2.visible = false;
+ pauseMenuBtn3.visible = false;
}
// When start is pressed, remove overlay and show game elements, start fruit spawning
var gameStarted = false;
startBtn.down = function (x, y, obj) {
Start button . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Settings button. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Left right button. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
A hand. In-Game asset. High contrast. No shadows. 2 d
Between two button a hand. In-Game asset. 2d. High contrast. No shadows
A farm. In-Game asset. 2d. High contrast. No shadows
Left button. In-Game asset. 2d. High contrast. No shadows
Devam et. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Basket. In-Game asset. 2d. High contrast. No shadows
Banana. In-Game asset. 2d. High contrast. No shadows
Left button. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Apple. In-Game asset. 2d. High contrast. No shadows
Grape. In-Game asset. 2d. High contrast. No shadows
Potato. In-Game asset. 2d. High contrast. No shadows