User prompt
write x text on close button
User prompt
make it 1
User prompt
10 count score dan sonra karakteri ters çevir
Code edit (10 edits merged)
Please save this source code
User prompt
records credits ve volume butonuna tıklayınca açılan pencere için second_menu kullanılsın
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
Adjust play button hit area to match visual size Adjust volume button hit area to match visual size Adjust credits button hit area to match visual size Adjust records button hit area to match visual size
User prompt
fare ile play volume credits records butonları arasında sorun farkettim Sorununuz, fare ile butonların etkileşime girdiğini kontrol ederken kullanılan çarpışma (hit) alanlarının görsel olarak beklediğinizden daha geniş hesaplanmasından kaynaklanıyor olabilir. Kodunuzda her buton için global koordinatlar şu şekilde hesaplanıyor: js Kopyala Düzenle var playGlobalX = playButton.x + menuContainer.x; var playGlobalY = playButton.y + menuContainer.y; if ( x >= playGlobalX - playButton.width / 2 && x <= playGlobalX + playButton.width / 2 && y >= playGlobalY - playButton.height / 2 && y <= playGlobalY + playButton.height / 2 ) { playButton.visible = true; } else { playButton.visible = false; } Eğer buton asset’lerinizin orijinal boyutları şeffaf kenarlar veya ekstra boşluk içeriyorsa, bu durumda görünür kısımdan daha geniş bir hit alanı oluşturulabilir. Ayrıca, eğer asset’ler üzerinde ölçekleme veya farklı pivot/anchor ayarları varsa, hesaplanan koordinatlar beklenmedik sonuçlar verebilir. Aşağıdaki öneriler sorunu çözmenize yardımcı olabilir: Asset Boyutlarını Kontrol Edin: Buton resimlerinin (örneğin button_play, button_credits vs.) gerçek görsel alanının, tanımladığınız width ve height değerleriyle örtüştüğünden emin olun. Eğer asset’leriniz fazladan şeffaf boşluk içeriyorsa, bu değeri düşürmeyi düşünebilirsiniz. Özel Hit Area Tanımlaması: Eğer görseldeki buton kısmı daha küçükse, butonlara özel hit alanları belirleyebilirsiniz. Örneğin, PIXI.js kullanıyorsanız şöyle bir hitArea tanımlayabilirsiniz: js Kopyala Düzenle playButton.hitArea = new PIXI.Rectangle( -playButton.width / 4, -playButton.height / 4, playButton.width / 2, playButton.height / 2 ); Bu sayede butonun aktif alanını, görselin ortasındaki kısım ile sınırlandırabilirsiniz. (Benzer tanımlamayı diğer butonlar için de yapabilirsiniz.) Hesaplamalarda Offset Uygulaması: Eğer görsel boyutları doğruysa ama yine de istenenden büyük bir etkileşim alanı varsa, koşul içerisinde kullanılan değerleri manuel olarak azaltabilirsiniz. Örneğin: js Kopyala Düzenle var offsetX = 10, offsetY = 10; // deneyerek ayarlayabileceğiniz offset değerleri if ( x >= playGlobalX - playButton.width / 2 + offsetX && x <= playGlobalX + playButton.width / 2 - offsetX && y >= playGlobalY - playButton.height / 2 + offsetY && y <= playGlobalY + playButton.height / 2 - offsetY ) { playButton.visible = true; } else { playButton.visible = false; } Bu yöntemle butonların aktif alanlarını biraz küçültebilirsiniz. Menu Container’ın Konumu ve Ölçeklendirmesi: Menü container’ın (menuContainer) pozisyonu ve varsa ölçeklendirmesi de global koordinatların doğru hesaplanmasında rol oynar. Container’ın pivot ve scale ayarlarının doğru yapıldığından emin olun. Özetle, çarpışma alanlarınızın beklediğiniz görsel alanla uyuşmaması, asset’lerin orijinal boyutları, pivot/anchor ayarları veya ekstra şeffaf boşluklardan kaynaklanıyor olabilir. Yukarıdaki yöntemlerden bir veya birkaçını uygulayarak daha hassas bir buton etkileşimi elde edebilirsiniz. Umarım bu öneriler sorununuzu çözmenize yardımcı olur!
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Game over sonrası çıkan ekranın animasyon hızının, play butonuyla başlayan menü animasyonuyla aynı olmasını istiyorsanız, game over animasyonunda kullanılan süreyi de play animasyonuyla uyumlu hale getirmeniz gerekir. Örneğin, play animasyonunda süreyi 1.5 kat hızlandırarak şöyle ayarlamıştınız: js Kopyala Düzenle var animationDuration = (16.5 * 5) / 1.5; Game over animasyonunda ise mevcutta: js Kopyala Düzenle var animationDuration = 166.5 / 2; olarak tanımlanmış. İki animasyonun da aynı hızda gerçekleşmesini istiyorsanız, game over kısmındaki bu satırı play animasyonundaki değeri kullanacak şekilde güncelleyebilirsiniz: js Kopyala Düzenle var animationDuration = (16.5 * 5) / 1.5; Böylece her iki animasyon aynı süreye sahip olup, aynı hızda gerçekleşecektir.
User prompt
Kodunuzda menü animasyonunun süresi şu satırda belirleniyor: js Kopyala Düzenle var animationDuration = 16.5 * 5; // Duration in milliseconds, slowed down by 5 times Animasyonu 1.5 kat hızlandırmak, mevcut süreyi 1.5'e bölmek anlamına gelir. Bu durumda, yeni süre: js Kopyala Düzenle var animationDuration = (16.5 * 5) / 1.5; olacaktır. Bu değişiklik, animasyonun 1.5 kat daha hızlı gerçekleşmesini sağlayacaktır.
User prompt
Kodunuzda play butonuna basıldığında menü animasyonunun hızını kontrol eden kısımda, animasyon süresi "animationDuration" değişkeninde belirleniyor. Animasyonu 2 kat yavaşlatmak için bu değeri 2 ile çarpabilirsiniz. Şu anki kodunuzda: js Kopyala Düzenle var animationDuration = 16.5 * 5; // Duration in milliseconds, slowed down by 5 times olarak tanımlanmış. Bunu 2 kat yavaşlatmak için, sürenin iki katına çıkması gerekir. Yani: js Kopyala Düzenle var animationDuration = 16.5 * 5 * 2; olarak güncellemeniz yeterli olacaktır. Böylece animasyon süresi iki kat artar ve menü daha yavaş iner.
User prompt
Speed down the menu animation when the play button pressed to 2 times slower ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
game overdan sonra bekleme süresi 0.3 saniye azalsın
User prompt
playe basınca aşağı inen menu hızı aynı kalsın ölünce yukarı çıkan menu 2 kat hızlansın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
playe basınca aşağı inen menu 5 kat daha yavaş insin aşağıdan yukarı çıkan menu hızı olduğu gibi kalsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
playe basınca aşağı inen menu 3 kat daha yavaş insin aşağıdan yukarı çıkan menu hızı olduğu gibi kalsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Slow down the menu animation when the play button is pressed to 3 times slower. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/**** * Classes ****/ // Character: Dokunulduğunda zıplar. var Character = Container.expand(function () { var self = Container.call(this); self.attachAsset('character', { anchorX: 0.5, anchorY: 0.5 }); self.zIndex = 4; self.velocityY = 0; self.gravity = 0.3; self.jumpStrength = -12; self.width = 350; self.height = 300; self.update = function () { if (gameStarted && !gameOver) { self.velocityY += self.gravity; self.y += self.velocityY; if (self.y > groundY - 100) { self.y = groundY - 100; self.velocityY = 0; gameOver = true; endGame(); } var characterLeft = self.x - self.width / 2; var characterRight = self.x + self.width / 2; var characterTop = self.y - self.height / 2; var characterBottom = self.y + self.height / 2; // Ekran dışına çıkma kontrolü if (characterLeft + self.width / 2 < 0 || characterRight - self.width / 2 > screenRight || characterTop + self.height / 2 < 0 || characterBottom - self.height / 2 > groundY) { gameOver = true; endGame(); } // Çarpışma kontrolü: Tube ve Tree game.children.forEach(function (child) { if (child instanceof Tube) { var tubeLeft = child.x - child.bottomTube.width / 2; var tubeRight = child.x + child.bottomTube.width / 2; var safeGapLowerEdge = child.y - child.bottomTube.height; var safeGapUpperEdge = -gapOffset + child.topTube.height; if (self.x + self.width / 2 > tubeLeft && self.x - self.width / 2 < tubeRight) { if (self.y < safeGapUpperEdge || self.y > safeGapLowerEdge) { gameOver = true; endGame(); } } } else if (child instanceof Tree) { var treeLeft = child.x - child.bottomTree.width / 2; var treeRight = child.x + child.bottomTree.width / 2; var safeGapLowerEdge = child.y - child.bottomTree.height; var safeGapUpperEdge = -gapOffset + child.topTree.height; if (self.x + self.width / 2 > treeLeft && self.x - self.width / 2 < treeRight) { if (self.y < safeGapUpperEdge || self.y > safeGapLowerEdge) { gameOver = true; endGame(); } } } }); } }; self.jump = function () { if (!gameOver) { self.velocityY = self.jumpStrength; } }; return self; }); // GameOverText class var GameOverText = Container.expand(function () { var self = Container.call(this); self.text = new Text2("GAME OVER", { fontFamily: "Arial", fontSize: 2250, fill: 0xFF0000, align: "center", fontWeight: "bold" }); self.text.anchorX = 0.5; self.text.anchorY = 0.5; self.addChild(self.text); self.zIndex = 100; return self; }); // Tree class: Üst ve alt ağaç oluşturma var Tree = Container.expand(function () { var self = Container.call(this); var bottomUnit = Math.floor(Math.random() * 8) + 1; var topUnit = 9 - bottomUnit; var unitSize = groundY / totalUnits; var bottomHeight = bottomUnit * unitSize; var topHeight = topUnit * unitSize; self.y = groundY; self.bottomTree = self.attachAsset('tree', { anchorX: 0.5, anchorY: 1, width: 300, height: bottomHeight, flipY: false }); self.topTree = self.attachAsset('tree', { anchorX: 0.5, anchorY: 0.5, width: 300, height: topHeight, flipY: false }); self.topTree.rotation = Math.PI; self.topTree.y = -groundY - gapOffset + topHeight / 2; self.zIndex = 1; self.x = 2048 + 800; self.velocityX = -3.6; self.spawned = false; self.prevX = self.x; self.update = function () { if (gameStarted && !gameOver) { self.x += self.velocityX; // Sırayla ağaç-boru üretimi if (!self.spawned && self.prevX > treeSpawnThreshold && self.x <= treeSpawnThreshold) { self.spawned = true; var newTube = new Tube(); newTube.x = 2048 + 800; game.addChild(newTube); lastSpawner = newTube; } self.prevX = self.x; // Geçme sayacı if (!self.passed && character.x > self.x + self.bottomTree.width / 2) { self.passed = true; passCounter += 1; counterText.setText(passCounter); } } }; return self; }); // Tube class: Üst ve alt boru oluşturma var Tube = Container.expand(function () { var self = Container.call(this); var bottomUnit = Math.floor(Math.random() * 8) + 1; var topUnit = 9 - bottomUnit; var unitSize = groundY / totalUnits; var bottomHeight = bottomUnit * unitSize; var topHeight = topUnit * unitSize; self.y = groundY; self.bottomTube = self.attachAsset('tube', { anchorX: 0.5, anchorY: 1, width: 300, height: bottomHeight, flipY: false }); self.topTube = self.attachAsset('tube', { anchorX: 0.5, anchorY: 0.5, width: 300, height: topHeight, flipY: false }); self.topTube.rotation = Math.PI; self.topTube.y = -groundY - gapOffset + topHeight / 2; self.zIndex = 1; self.x = 2048 + 800; self.velocityX = -3.6; self.spawned = false; self.prevX = self.x; self.update = function () { if (gameStarted && !gameOver) { self.x += self.velocityX; // Sırayla boru-ağaç üretimi if (!self.spawned && self.prevX > tubeSpawnThreshold && self.x <= tubeSpawnThreshold) { self.spawned = true; var newTree = new Tree(); newTree.x = 2048 + 800; game.addChild(newTree); lastSpawner = newTree; } self.prevX = self.x; // Geçme sayacı if (!self.passed && character.x > self.x + self.bottomTube.width / 2) { self.passed = true; passCounter += 1; counterText.setText(passCounter); } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ /**** * Global Variables & Helper Functions ****/ var groundY = 2732; var menuOpen = true; var volumeOn = true; var records = []; // En iyi 5 skoru saklar var gapOffset = 400; var gameStarted = false; var gameOver = false; var gameWait = false; // Oyun menüden çıkıp da henüz başlamamışken true olacak. var screenRight = 2048; var totalUnits = 10; var tubeSpawnThreshold, treeSpawnThreshold; var lastSpawner = null; var gameOverText = null; var passCounter = 0; var lastScore = 0; // Global lastScore variable function centerX() { return 2048 / 2; } function centerY() { return groundY / 2; } tubeSpawnThreshold = centerX() + (screenRight - centerX()) / 2; treeSpawnThreshold = centerX() + 3 * (screenRight - centerX()) / 4; /**** * Menu Setup ****/ var menuContainer = new Container(); menuContainer.zIndex = 200; // Menü arka planları var menuBackground = LK.getAsset('menu_background', { anchorX: 0.5, anchorY: 0.5, x: centerX(), y: centerY() }); menuBackground.zIndex = 200; menuContainer.addChild(menuBackground); var menuBackgroundPart = LK.getAsset('menu_background_part', { anchorX: 0.5, anchorY: 0.19, x: centerX(), y: centerY() }); menuBackgroundPart.zIndex = menuBackground.zIndex + 1; // 201 menuContainer.addChild(menuBackgroundPart); // Butonlar ve Label’lar // PLAY var playButton = LK.getAsset('button_play', { anchorX: 0.5, anchorY: 0.5, x: centerX() - 20, y: centerY() + 195 }); playButton.visible = false; menuContainer.addChild(playButton); var playLabel = new Text2("PLAY", { fontFamily: "Arial", fontSize: 63.25 * 1.1 * 1.08, // 18% increase fill: 0xffffff }); playLabel.anchorX = 0.5; playLabel.anchorY = 0.5; playLabel.x = playButton.x - 45; playLabel.y = playButton.y - -30; playLabel.visible = true; playLabel.zIndex = 1000; // diğer öğelerden yüksek menuContainer.addChild(playLabel); // VOLUME var volumeButton = LK.getAsset('button_volume', { anchorX: 0.5, anchorY: 0.5, x: centerX() - 28, y: centerY() + 315 }); volumeButton.visible = false; menuContainer.addChild(volumeButton); var volumeLabel = new Text2("VOLUME", { fontFamily: "Arial", fontSize: 63.25 * 1.1 * 1.05 * 1.05 * 1.05, // 30% increase fill: 0xffffff }); volumeLabel.anchorX = 0.5; volumeLabel.anchorY = 0.5; volumeLabel.x = volumeButton.x - 60; volumeLabel.y = volumeButton.y - -50; // 12 piksel yukarı volumeLabel.visible = true; volumeLabel.zIndex = 1000; menuContainer.addChild(volumeLabel); // CREDITS var creditsButton = LK.getAsset('button_credits', { anchorX: 0.5, anchorY: 0.5, x: centerX() - 30, y: centerY() + 429 }); creditsButton.visible = false; menuContainer.addChild(creditsButton); var creditsLabel = new Text2("CREDITS", { fontFamily: "Arial", fontSize: 630.25 * 1.05 * 1.05 * 1.05, // 25% increase fill: 0xffffff }); creditsLabel.anchorX = 0.5; creditsLabel.anchorY = 0.5; creditsLabel.x = creditsButton.x - 63; creditsLabel.y = creditsButton.y - -45; creditsLabel.visible = true; creditsLabel.zIndex = 1000; menuContainer.addChild(creditsLabel); // RECORDS var recordsButton = LK.getAsset('button_records', { anchorX: 0.5, anchorY: 0.5, x: centerX() - 30, y: centerY() + 540 }); recordsButton.visible = false; menuContainer.addChild(recordsButton); var recordsLabel = new Text2("RECORDS", { fontFamily: "Arial", fontSize: 150.25 * 1.05 * 1.05 * 1.03 * 1.05, // 30% increase fill: 0xffffff }); recordsLabel.anchorX = 0.5; recordsLabel.anchorY = 0.5; recordsLabel.x = recordsButton.x - 67; recordsLabel.y = recordsButton.y - -40; // 12 piksel yukarı recordsLabel.visible = true; recordsLabel.zIndex = 1000; menuContainer.addChild(recordsLabel); // Ekranda sayacımız var counterText = new Text2('0', { size: 124.2, // 15% artış from 108 fill: 0xFFFFFF }); counterText.anchor.set(0, 0); counterText.x = 1320; counterText.y = 10; LK.gui.topLeft.addChild(counterText); // Arkaplanlar var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: centerX(), y: groundY / 2 }); background.zIndex = 0; game.addChild(background); var sky = LK.getAsset('sky', { anchorX: 0.5, anchorY: 0, x: centerX(), y: 0 }); sky.zIndex = 2; game.addChild(sky); var groundAsset = LK.getAsset('ground', { anchorX: 0.5, anchorY: 0.5, x: centerX(), y: groundY - -25 }); groundAsset.zIndex = 4.1; game.addChild(groundAsset); var ground2Asset = LK.getAsset('ground2', { anchorX: 0.5, anchorY: 0.5, x: centerX(), y: groundY - 40 }); ground2Asset.zIndex = 0.5; game.addChild(ground2Asset); // Karakteri ekle var character = game.addChild(new Character()); character.x = centerX(); character.y = groundY / 2; // Menü container'ı biraz aşağı kaydırma menuContainer.y += 100; game.addChild(menuContainer); /**** * Helper Functions: Credits, Volume & Records ****/ function createCommonCloseElements(modalWidth, modalHeight) { // close label: base close label font size (hesaplanmış değeri 35 * 1.16 * 1.15 * 1.1 * 1.2 ≈ 62) var closeLabel = new Text2("X", { fontFamily: "Arial", fontSize: Math.round(35 * 1.16 * 1.15), fill: 0xffffff, align: "center" }); closeLabel.anchorX = 0.5; closeLabel.anchorY = 0.5; closeLabel.zIndex = 10000; // Konum: sağ üst köşeye yakın (20px offset) closeLabel.x = centerX() + modalWidth / 2 - 65; closeLabel.y = centerY() - modalHeight / 2 + 40; // close button var radius = 25; var closeButton = LK.getAsset('button_close', { anchorX: 0.5, anchorY: 0.5, width: radius * 2.3 * 1.2, height: radius * 2.3 * 1.2 }); closeButton.zIndex = 10000; closeButton.x = closeLabel.x + 7; closeButton.y = closeLabel.y + 16; return { closeLabel: closeLabel, closeButton: closeButton }; } function showCredits() { var creditsContainer = new Container(); creditsContainer.zIndex = 300; // Modal boyutu: 1250x2000 var modalWidth = 1250, modalHeight = 2000; var bg = LK.getAsset('button_credits', { anchorX: 0.5, anchorY: 0.5, width: modalWidth, height: modalHeight, color: 0x000000 }); bg.x = centerX(); bg.y = centerY(); creditsContainer.addChild(bg); var creditsText = new Text2("Game by\nMustafa Talha ŞEN", { fontFamily: "Arial", fontSize: 5000, fill: 0xffffff, align: "center" }); creditsText.anchorX = 0.5; creditsText.anchorY = 0.5; creditsText.x = centerX() - 359; creditsText.y = centerY() - 800; creditsText.scale.set(3, 3); creditsContainer.addChild(creditsText); // Ortak close label ve button var commonClose = createCommonCloseElements(modalWidth, modalHeight); creditsContainer.addChild(commonClose.closeButton); creditsContainer.addChild(commonClose.closeLabel); commonClose.closeButton.on('down', function () { game.removeChild(creditsContainer); menuOpen = true; menuContainer.visible = true; }); game.addChild(creditsContainer); } function showVolume() { var volumeContainer = new Container(); volumeContainer.zIndex = 300; // Modal boyutu: 1250x2000 var modalWidth = 1250, modalHeight = 2000; var bg = LK.getAsset('button_credits', { anchorX: 0.5, anchorY: 0.5, width: modalWidth, height: modalHeight, color: 0x000000 }); bg.x = centerX(); bg.y = centerY(); volumeContainer.addChild(bg); var volumeText = new Text2("Volume Settings", { fontFamily: "Arial", fontSize: 5000, fill: 0xffffff }); volumeText.scale.set(3, 3); volumeText.anchorX = 0.5; volumeText.anchorY = 0.5; volumeText.x = centerX() - 275; volumeText.y = centerY() - 800; volumeContainer.addChild(volumeText); // Ortak close label ve button var commonClose = createCommonCloseElements(modalWidth, modalHeight); volumeContainer.addChild(commonClose.closeButton); volumeContainer.addChild(commonClose.closeLabel); commonClose.closeButton.on('down', function () { game.removeChild(volumeContainer); menuOpen = true; menuContainer.visible = true; }); game.addChild(volumeContainer); } function showRecords() { var recordsContainer = new Container(); recordsContainer.zIndex = 300; var modalWidth = 1500, modalHeight = 2200; var bg = LK.getAsset('button_credits', { anchorX: 0.5, anchorY: 0.5, width: modalWidth, height: modalHeight, color: 0x000000 }); bg.x = centerX(); bg.y = centerY(); recordsContainer.addChild(bg); var recordsTextStr = "Top Scores:\n"; for (var i = 0; i < records.length; i++) { recordsTextStr += i + 1 + ". " + records[i].score + " (Attempt " + records[i].attempt + ")\n"; } if (records.length === 0) { recordsTextStr += "No records yet."; } recordsTextStr += "\nAttempts: " + records.length; recordsTextStr += "\nLast Score: " + lastScore; var recordsText = new Text2(recordsTextStr, { fontFamily: "Arial", fontSize: 5000, fill: 0xffffff, align: "center" }); recordsText.anchorX = 0.5; recordsText.anchorY = 0.5; recordsText.x = centerX() - 280; recordsText.y = centerY() - 850; recordsText.scale.set(3, 3); recordsContainer.addChild(recordsText); var commonClose = createCommonCloseElements(modalWidth, modalHeight); recordsContainer.addChild(commonClose.closeButton); recordsContainer.addChild(commonClose.closeLabel); commonClose.closeButton.on('down', function () { game.removeChild(recordsContainer); menuOpen = true; menuContainer.visible = true; }); game.addChild(recordsContainer); } /**** * End Game & Reset Functions ****/ function endGame() { LK.effects.flashScreen(0xFF0000, 500); character.velocityY = character.jumpStrength; character.update = function () { if (gameOver) { character.velocityY += character.gravity; character.y += character.velocityY; if (character.y > groundY + character.height) { character.y = groundY + character.height; character.velocityY = 0; } } }; // Tüm hareket eden nesneleri durdur game.children.forEach(function (child) { if (child.velocityX) { child.velocityX = 0; } }); game.touchDisabled = true; lastScore = passCounter; // Skoru kaydet records.push({ score: passCounter, attempt: records.length + 1 }); records.sort(function (a, b) { return b.score - a.score; }); if (records.length > 5) { records = records.slice(0, 5); } LK.setTimeout(function () { game.touchDisabled = false; menuOpen = true; menuContainer.visible = true; var startY = groundY + 100; // Ekranın altından var endY = centerY() - 1270; // Son konum var animationDuration = 16.5 * 5 / 1.5; var startTime = Date.now(); function animateMenu() { var currentTime = Date.now(); var elapsedTime = currentTime - startTime; var progress = Math.min(elapsedTime / animationDuration, 1); menuContainer.y = startY + (endY - startY) * progress; if (progress < 1) { LK.setTimeout(animateMenu, 16); } } animateMenu(); }, 1700); LK.setTimeout(function () { resetGame(); }, 2000); } function resetGame() { if (gameOverText) { game.removeChild(gameOverText); gameOverText = null; } var objectsToRemove = []; game.children.forEach(function (child) { if (child instanceof Tree || child instanceof Tube) { objectsToRemove.push(child); } }); objectsToRemove.forEach(function (obj) { game.removeChild(obj); }); game.removeChild(character); character = game.addChild(new Character()); character.x = centerX(); character.y = groundY / 2; gameStarted = false; gameOver = false; lastSpawner = null; passCounter = 0; counterText.setText(passCounter); } /**** * Eliptik hit testi için yardımcı fonksiyon ****/ function checkEllipseHover(button, lx, ly) { // Butonun merkezini (button.x, button.y), yarıçaplarını (button.width/2, button.height/2) kabul ediyoruz var dx = lx - button.x; var dy = ly - button.y; var rx = button.width / 2; var ry = button.height / 2; // Elips formülü: (dx^2 / rx^2) + (dy^2 / ry^2) <= 1 ise içindedir return dx * dx / (rx * rx) + dy * dy / (ry * ry) <= 1; } /**** * Fare hareketinde hover kontrolü: butonlar yalnızca imleç üzerindeyken görünür ****/ game.move = function (x, y, obj) { // Menü container'a göre fare konumunu bul var localX = x - menuContainer.x; var localY = y - menuContainer.y; // Her buton için eliptik kontrol yapıyoruz playButton.visible = checkEllipseHover(playButton, localX, localY); volumeButton.visible = checkEllipseHover(volumeButton, localX, localY); creditsButton.visible = checkEllipseHover(creditsButton, localX, localY); recordsButton.visible = checkEllipseHover(recordsButton, localX, localY); }; /**** * Touch Event ****/ game.down = function (x, y, obj) { if (menuOpen) { // Menü üzerindeyken butonlara tıklama kontrolü de eliptik olsun: var localX = x - menuContainer.x; var localY = y - menuContainer.y; if (checkEllipseHover(playButton, localX, localY)) { // Play butonuna basıldı var _animateMenu = function animateMenu() { var currentTime = Date.now(); var elapsedTime = currentTime - startTime; var progress = Math.min(elapsedTime / animationDuration, 1); menuContainer.y = startY + (endY - startY) * progress; if (progress < 1) { LK.setTimeout(_animateMenu, 1); } else { menuOpen = false; menuContainer.visible = false; gameWait = true; } }; var animationDuration = 16.5 * 5 * 2 / 1.5; var startTime = Date.now(); var startY = menuContainer.y; var endY = centerY() + 100; _animateMenu(); return; } else if (checkEllipseHover(volumeButton, localX, localY)) { showVolume(); } else if (checkEllipseHover(creditsButton, localX, localY)) { showCredits(); } else if (checkEllipseHover(recordsButton, localX, localY)) { showRecords(); } return; } else if (gameOver) { if (!game.touchDisabled) { menuOpen = true; menuContainer.visible = true; resetGame(); } } else { if (gameWait) { // Oyun henüz başlamamış, ilk dokunuş gameWait = false; gameStarted = true; var initialTube = new Tube(); game.addChild(initialTube); lastSpawner = initialTube; character.jump(); } else { // Oyun zaten başlamış, normal zıplama character.jump(); character.rotation = 0.1; LK.setTimeout(function () { character.rotation = 0; }, 200); } } }; /**** * Game Loop ****/ game.update = function () { game.children.forEach(function (child) { if (child.update) { child.update(); } }); game.children.sort(function (a, b) { return (a.zIndex || 0) - (b.zIndex || 0); }); };
===================================================================
--- original.js
+++ change.js
@@ -252,9 +252,9 @@
var playButton = LK.getAsset('button_play', {
anchorX: 0.5,
anchorY: 0.5,
x: centerX() - 20,
- y: centerY() + 185
+ y: centerY() + 195
});
playButton.visible = false;
menuContainer.addChild(playButton);
var playLabel = new Text2("PLAY", {
@@ -265,18 +265,18 @@
});
playLabel.anchorX = 0.5;
playLabel.anchorY = 0.5;
playLabel.x = playButton.x - 45;
-playLabel.y = playButton.y - -40;
+playLabel.y = playButton.y - -30;
playLabel.visible = true;
playLabel.zIndex = 1000; // diğer öğelerden yüksek
menuContainer.addChild(playLabel);
// VOLUME
var volumeButton = LK.getAsset('button_volume', {
anchorX: 0.5,
anchorY: 0.5,
- x: centerX() - 8,
- y: centerY() + 290
+ x: centerX() - 28,
+ y: centerY() + 315
});
volumeButton.visible = false;
menuContainer.addChild(volumeButton);
var volumeLabel = new Text2("VOLUME", {
@@ -286,9 +286,9 @@
fill: 0xffffff
});
volumeLabel.anchorX = 0.5;
volumeLabel.anchorY = 0.5;
-volumeLabel.x = volumeButton.x - 70;
+volumeLabel.x = volumeButton.x - 60;
volumeLabel.y = volumeButton.y - -50; // 12 piksel yukarı
volumeLabel.visible = true;
volumeLabel.zIndex = 1000;
menuContainer.addChild(volumeLabel);
@@ -317,10 +317,10 @@
// RECORDS
var recordsButton = LK.getAsset('button_records', {
anchorX: 0.5,
anchorY: 0.5,
- x: centerX() - 20,
- y: centerY() + 525
+ x: centerX() - 30,
+ y: centerY() + 540
});
recordsButton.visible = false;
menuContainer.addChild(recordsButton);
var recordsLabel = new Text2("RECORDS", {