User prompt
✅ Adjust close button position in showCredits to be 90px left and 30px down ✅ Adjust close button position in showVolume to be 90px left and 30px down ✅ Adjust close button position in showRecords to be 90px left and 30px down
User prompt
✅ Adjust close button position in showCredits to be 60px left and 30px down ✅ Adjust close button position in showVolume to be 60px left and 30px down ✅ Adjust close button position in showRecords to be 60px left and 30px down
User prompt
Adjust close button position in showCredits to be 90px down Adjust close button position in showVolume to be 90px down Adjust close button position in showRecords to be 90px down
User prompt
✅ Adjust close button position in showCredits to be 90px left and 90px down ✅ Adjust close button position in showVolume to be 90px left and 90px down ✅ Adjust close button position in showRecords to be 90px left and 90px down
User prompt
Close butonunu biraz daha aşağı ve sola kaydırmak için, şu anki konumlandırmada kullandığınız koordinatlara ufak ekleme/çıkarma yapabilirsiniz. Örneğin: javascript Kopyala Düzenle // Eski hal: commonClose.closeButton.x = bg.x + modalWidth / 2 - (commonClose.closeButton.width / 2); commonClose.closeButton.y = bg.y - modalHeight / 2 + (commonClose.closeButton.height / 2); // Yeni hal (örnek olarak 30px sola ve 30px aşağı): commonClose.closeButton.x = bg.x + modalWidth / 2 - (commonClose.closeButton.width / 2) - 30; commonClose.closeButton.y = bg.y - modalHeight / 2 + (commonClose.closeButton.height / 2) + 30; Bu sayede buton, sağ üst köşeden 30 piksel sola ve 30 piksel aşağı kaymış olur. Değerleri dilediğiniz gibi ayarlayarak (örneğin -15 ve +20 gibi) görsel açıdan daha hoş bir konum yakalayabilirsiniz. Aynı mantığı, diğer modal pencerelerinizin (showCredits, showVolume vb.) close butonlarını da konumlandırırken uygulayabilirsiniz.
User prompt
Gördüğünüz gibi şu anda modal oluştururken recordsContainer (ve diğer modal container'lar) ekranda (0,0) konumunda duruyor, fakat bg (arka plan resmi) kendi içinde centerX() ve centerY() değerlerine konumlanıyor. Bu durumda, close butonunu (0,0) konumuna yerleştirirseniz aslında ekranda sol üst köşeye gider. İstediğiniz: Close butonunun, modal pencerenin (arka plan resminin) sağ üst köşesinde görünmesi. Bunun için yapmanız gereken, close butonunu “arka plan resmine göre” konumlandırmak. Örneğin, showRecords fonksiyonuna (veya diğer modal fonksiyonlarına) aşağıdaki mantığı uygulayabilirsiniz: javascript Kopyala Düzenle function showRecords() { var recordsContainer = new Container(); recordsContainer.zIndex = 300; // 1) Modal boyutları var modalWidth = 1500, modalHeight = 2200; // 2) Arka planı ortala var bg = LK.getAsset('second_menu', { anchorX: 0.5, anchorY: 0.5, width: modalWidth, height: modalHeight, color: 0x000000 }); // Bu container henüz (0,0)'da duruyor, fakat bg'yi ekran merkezine yerleştiriyoruz: bg.x = centerX(); bg.y = centerY(); recordsContainer.addChild(bg); // 3) İçerik (text vb.) var recordsTextStr = "Top Scores:\nNo records yet.\nAttempts: 0\nLast Score: 0"; var recordsText = new Text2(recordsTextStr, { fontFamily: "Arial", fontSize: 5000, fill: 0xffffff, align: "center" }); recordsText.anchorX = 0.5; recordsText.anchorY = 0.5; // Metni de ekranda ortalamak isterseniz, aynı şekilde bg.x, bg.y baz alabilirsiniz: recordsText.x = bg.x; recordsText.y = bg.y - 100; recordsText.scale.set(3, 3); recordsContainer.addChild(recordsText); // 4) Close butonu oluştur var commonClose = createCommonCloseElements(modalWidth, modalHeight); recordsContainer.addChild(commonClose.closeButton); // İşte burada, close butonunu modalın (arka plan resminin) sağ üst köşesine ayarlıyoruz: // bg'nin merkezi bg.x, bg.y // Sağ üst köşe: (bg.x + modalWidth/2, bg.y - modalHeight/2) // Biraz da yarıçap kadar içeri kaydırmak isterseniz: commonClose.closeButton.x = bg.x + modalWidth / 2 - (commonClose.closeButton.width / 2); commonClose.closeButton.y = bg.y - modalHeight / 2 + (commonClose.closeButton.height / 2); // 5) Close butonuna tıklayınca container'ı kapat commonClose.closeButton.on('down', function () { game.removeChild(recordsContainer); menuOpen = true; menuContainer.visible = true; }); // 6) Ekrana ekle game.addChild(recordsContainer); } Neden Bu Şekilde? recordsContainer varsayılan olarak (0,0) konumunda duruyor. bg (arka plan) recordsContainer içine yerleştiriliyor ama kendisi centerX(), centerY() değerlerine oturtuluyor. Dolayısıyla container’ın lokal koordinat düzleminde bg (centerX(), centerY())’de bulunuyor. Close butonunu (0,0) yerine, bg’nin sağ üst köşesine göre hesaplayıp yerleştirirseniz istediğiniz noktaya konumlanacaktır. Diğer Modal’lar İçin showCredits, showVolume, showRecords gibi bütün modal fonksiyonlarında aynı mantığı uygulayabilirsiniz. Eğer pivot ayarını (örn. recordsContainer.pivot.x = modalWidth/2;) kullanarak container’ın merkezini (0,0) yaparsanız, o zaman bg.x = 0; bg.y = 0; şeklinde kullanabilir, close butonunu da x = modalWidth/2, y = -modalHeight/2 gibi direkt container koordinatlarıyla yerleştirebilirsiniz. Bu şekilde close butonu modal pencerenin sağ üst köşesinde düzgün bir biçimde görünür hale gelecektir.
User prompt
close butttonu 100 pixel aşağı 100 pixel sola itele
User prompt
close buttonu ve close text i 50 pixel aşağı itele
User prompt
Gördüğünüz gibi şu anda modal oluştururken recordsContainer (ve diğer modal container'lar) ekranda (0,0) konumunda duruyor, fakat bg (arka plan resmi) kendi içinde centerX() ve centerY() değerlerine konumlanıyor. Bu durumda, close butonunu (0,0) konumuna yerleştirirseniz aslında ekranda sol üst köşeye gider. İstediğiniz: Close butonunun, modal pencerenin (arka plan resminin) sağ üst köşesinde görünmesi. Bunun için yapmanız gereken, close butonunu “arka plan resmine göre” konumlandırmak. Örneğin, showRecords fonksiyonuna (veya diğer modal fonksiyonlarına) aşağıdaki mantığı uygulayabilirsiniz: javascript Kopyala Düzenle function showRecords() { var recordsContainer = new Container(); recordsContainer.zIndex = 300; // 1) Modal boyutları var modalWidth = 1500, modalHeight = 2200; // 2) Arka planı ortala var bg = LK.getAsset('second_menu', { anchorX: 0.5, anchorY: 0.5, width: modalWidth, height: modalHeight, color: 0x000000 }); // Bu container henüz (0,0)'da duruyor, fakat bg'yi ekran merkezine yerleştiriyoruz: bg.x = centerX(); bg.y = centerY(); recordsContainer.addChild(bg); // 3) İçerik (text vb.) var recordsTextStr = "Top Scores:\nNo records yet.\nAttempts: 0\nLast Score: 0"; var recordsText = new Text2(recordsTextStr, { fontFamily: "Arial", fontSize: 5000, fill: 0xffffff, align: "center" }); recordsText.anchorX = 0.5; recordsText.anchorY = 0.5; // Metni de ekranda ortalamak isterseniz, aynı şekilde bg.x, bg.y baz alabilirsiniz: recordsText.x = bg.x; recordsText.y = bg.y - 100; recordsText.scale.set(3, 3); recordsContainer.addChild(recordsText); // 4) Close butonu oluştur var commonClose = createCommonCloseElements(modalWidth, modalHeight); recordsContainer.addChild(commonClose.closeButton); // İşte burada, close butonunu modalın (arka plan resminin) sağ üst köşesine ayarlıyoruz: // bg'nin merkezi bg.x, bg.y // Sağ üst köşe: (bg.x + modalWidth/2, bg.y - modalHeight/2) // Biraz da yarıçap kadar içeri kaydırmak isterseniz: commonClose.closeButton.x = bg.x + modalWidth / 2 - (commonClose.closeButton.width / 2); commonClose.closeButton.y = bg.y - modalHeight / 2 + (commonClose.closeButton.height / 2); // 5) Close butonuna tıklayınca container'ı kapat commonClose.closeButton.on('down', function () { game.removeChild(recordsContainer); menuOpen = true; menuContainer.visible = true; }); // 6) Ekrana ekle game.addChild(recordsContainer); } Neden Bu Şekilde? recordsContainer varsayılan olarak (0,0) konumunda duruyor. bg (arka plan) recordsContainer içine yerleştiriliyor ama kendisi centerX(), centerY() değerlerine oturtuluyor. Dolayısıyla container’ın lokal koordinat düzleminde bg (centerX(), centerY())’de bulunuyor. Close butonunu (0,0) yerine, bg’nin sağ üst köşesine göre hesaplayıp yerleştirirseniz istediğiniz noktaya konumlanacaktır. Diğer Modal’lar İçin showCredits, showVolume, showRecords gibi bütün modal fonksiyonlarında aynı mantığı uygulayabilirsiniz. Eğer pivot ayarını (örn. recordsContainer.pivot.x = modalWidth/2;) kullanarak container’ın merkezini (0,0) yaparsanız, o zaman bg.x = 0; bg.y = 0; şeklinde kullanabilir, close butonunu da x = modalWidth/2, y = -modalHeight/2 gibi direkt container koordinatlarıyla yerleştirebilirsiniz. Bu şekilde close butonu modal pencerenin sağ üst köşesinde düzgün bir biçimde görünür hale gelecektir.
User prompt
close buttonu ekranın ortasına getir
User prompt
close buttonu sağ tarafa 500 pixel itele
User prompt
close button ekranın ortasına gelsin
User prompt
Sorunun kaynağı, modal container içinde kullanılan modalWidth ve modalHeight değişkenlerinin sıralamasından kaynaklanıyor. Örneğin, showCredits fonksiyonunda önce pivot ayarlarını yaparken bu değişkenler kullanılıyor, ancak henüz tanımlanmamışlar. Bu nedenle pivot değerleri (ve dolayısıyla close button konumu) NaN oluyor ve buton görünmüyor. Aşağıdaki örnekte değişken tanımlamalarını en başa alırsanız sorun çözülecektir: javascript Kopyala Düzenle function showCredits() { // Önce modal ölçülerini tanımlayın var modalWidth = 1250, modalHeight = 2000; var creditsContainer = new Container(); creditsContainer.zIndex = 300; // Pivot'u modalın ortası olarak ayarlayın creditsContainer.pivot.x = modalWidth / 2; creditsContainer.pivot.y = modalHeight / 2; creditsContainer.x = centerX(); creditsContainer.y = centerY(); var bg = LK.getAsset('second_menu', { anchorX: 0.5, anchorY: 0.5, width: modalWidth, height: modalHeight, color: 0x000000 }); bg.x = 0; bg.y = 0; 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 = 0; // Container içinde merkezde konumlandırabilirsiniz creditsText.y = -modalHeight / 4; // Örneğin, üst kısımda creditsText.scale.set(3, 3); creditsContainer.addChild(creditsText); var commonClose = createCommonCloseElements(modalWidth, modalHeight); creditsContainer.addChild(commonClose.closeButton); commonClose.closeButton.on('down', function () { game.removeChild(creditsContainer); menuOpen = true; menuContainer.visible = true; }); game.addChild(creditsContainer); } Bu düzenlemede: Modal ölçüleri önce tanımlanıyor: Böylece pivot ayarlarında ve close button konumlandırmasında doğru değerler kullanılıyor. Container pivot ayarı: Container’ın pivot’u modalın ortası olarak ayarlanıyor; böylece container içindeki öğeler, container’ın merkezine göre konumlanır. Close button konumu: createCommonCloseElements fonksiyonunda verilen modalWidth ve modalHeight değerleri doğru şekilde kullanılarak buton, container’ın sağ üst köşesine yerleşir. Bu değişikliklerden sonra close button’un modal üzerinde görünmesi gerekir.
User prompt
Sorunun temelinde, close button'un modal container içindeki konumlandırılmasında oluşan koordinat sistemi uyuşmazlığı yatıyor. Şu anda oluşturduğunuz createCommonCloseElements fonksiyonu, modalWidth ve modalHeight değerlerine göre close button'u hesaplıyor: closeButton.x = modalWidth/2 - radius closeButton.y = -modalHeight/2 + radius Ancak, creditsContainer (ve diğer modal container’lar) için origin (0,0) noktası, modalın ortası olarak ayarlanmadığından bu koordinatlar beklediğiniz yerden çok farklı bir noktaya denk gelebilir (örneğin, ekranın dışında). Çözüm Önerileri: Modal Container Pivot’ini Ayarlayın: Modal container’ın pivot (kesişim) noktasını modalın ortası olarak ayarlarsanız, container içerisindeki koordinatlar modalın merkezine göre hesaplanır. Örneğin, showCredits fonksiyonunda: javascript Kopyala Düzenle var modalWidth = 1250, modalHeight = 2000; var creditsContainer = new Container(); creditsContainer.zIndex = 300; // Pivot'u modalın ortası olarak ayarla creditsContainer.pivot.x = modalWidth / 2; creditsContainer.pivot.y = modalHeight / 2; // Ardından container'ı ekranın ortasına yerleştir creditsContainer.x = centerX(); creditsContainer.y = centerY(); Daha sonra, bg, close button ve diğer öğeleri container içerisinde modal merkezine göre konumlandırabilirsiniz (örneğin bg için x = 0, y = 0). Close Button Konumunu Doğrudan Modal'a Göre Ayarlayın: Eğer pivot ayarlamak istemiyorsanız, close button'u modal background'un (bg) koordinatlarına göre pozisyonlayabilirsiniz. Örneğin: javascript Kopyala Düzenle // bg'nin ekranın ortasında olduğunu varsayalım: bg.x = centerX(); bg.y = centerY(); // Close button'u bg'nin sağ üst köşesine göre konumlandırın: closeButton.x = bg.x + modalWidth/2 - radius; closeButton.y = bg.y - modalHeight/2 + radius; Böylece close button modalın sağ üst köşesine yerleşir. Bu düzenlemeler yapıldığında close button'un modal üzerinde görünür hale gelmesi gerekir. Konumlandırmayı, modal container’ın pivot veya child öğelerle olan ilişkisinden bağımsız tutmak, sorunu çözecektir.
User prompt
Close button'un görünmemesinin birkaç nedeni olabilir: Konumlandırma Sorunu: createCommonCloseElements fonksiyonunda close button ve X yazısı için x/y koordinatları 0 olarak ayarlanmış. Eğer modal container'ın orijin noktasına göre (0,0) konumlandırılmışsa, bu konum görünür alanda olmayabilir. Önceki sürümde close button modalın sağ üst köşesinde konumlandırılmıştı. Modalın sağ üst köşesine yerleştirmek için modalWidth ve modalHeight kullanarak uygun x/y değerleri ayarlamanız gerekebilir. Anchor Ayarları: Close button'u oluştururken kullanılan anchorX ve anchorY değerleri (örneğin, 1.85 ve -1.10) close button'un render konumunu beklenmedik şekilde değiştirebilir. Normalde, butonun merkezlenmesi için anchor değerlerinin 0.5 olarak ayarlanması daha uygun olabilir. Çift Ekleme: closeLabel, closeButton’un child’ı olarak ekleniyor. Sonrasında hem closeButton hem de closeLabel ayrı ayrı modal container'a ekleniyor. Eğer closeLabel zaten closeButton’a eklenmişse, bunu tekrar eklemek karmaşaya neden olabilir. Önerilen Çözüm: Aşağıdaki örnek, close button'un modalın sağ üst köşesine yerleşmesini sağlayacak şekilde ayarlanmış bir fonksiyon örneğidir: javascript Kopyala Düzenle function createCommonCloseElements(modalWidth, modalHeight) { // X yazısı için daha makul bir font boyutu var closeLabel = new Text2("X", { fontFamily: "Arial", fontSize: 75, fill: 0xffffff, align: "center" }); closeLabel.anchorX = 0.5; closeLabel.anchorY = 0.5; closeLabel.zIndex = 10000; var radius = 50; // Buton asset'ini daha uygun anchor değerleriyle çağırıyoruz 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; // Modal container'ın sağ üst köşesine konumlandırma (örneğin) closeButton.x = modalWidth / 2 - radius; closeButton.y = -modalHeight / 2 + radius; // closeLabel'i butonun child'ı olarak ekleyin closeButton.addChild(closeLabel); // Tek seferde closeButton'u modal container'a ekleyin return { closeButton: closeButton }; } Uygulama Önerileri: Modal container oluştururken, container'ın orijinini (0,0) modalın ortası olarak ayarlıyorsanız, close button'un konumunu buna göre ayarlayın. Örneğin, container'ın merkezini (0,0) kabul ediyorsanız, sağ üst köşe için x = modalWidth/2 - offset, y = -modalHeight/2 + offset gibi değerler kullanın. closeLabel'in ayrı olarak modal container'a eklenmesine gerek yok; closeLabel zaten closeButton'un child’ı olarak eklenmiş. Anchor değerlerini kontrol ederek, butonun doğru render edilip edilmediğini test edin. Bu ayarlamalar yapıldığında close button'un eski güzel konumuna geri dönmesi ve görünür olması beklenir.
User prompt
Sorunun kaynağı, close "X" metni için tanımlanan yazı tipi boyutunun (font size) çok yüksek hesaplanması gibi görünüyor. Fonksiyonda: javascript Kopyala Düzenle var closeLabel = new Text2("X", { fontFamily: "Arial", fontSize: Math.round(350000 * 10000.16 * 10000.15), fill: 0xffffff, align: "center" }); bu hesaplama yaklaşık 3.5e13 gibi inanılmaz yüksek bir değer üretiyor. Bu kadar yüksek bir yazı tipi boyutu, metnin ya render edilmemesine ya da beklenmeyen şekilde ekrandan uzaklaşmasına neden olabilir. Çözüm Önerisi: Yazı tipi boyutunu daha makul bir değere (örneğin 50-100 arası) ayarlayarak close "X" metninin, close button’un üzerinde düzgünce görünmesini sağlayabilirsiniz. Ek olarak, closeLabel’in konumlandırması da gözden geçirilebilir. Eğer closeLabel, closeButton’un child’ı olarak ekleniyorsa, pozisyon değerlerini relative (örneğin 0,0) yaparak close button’un tam ortasında olmasını sağlayabilirsiniz. Bu düzenlemelerle "X" metninin görünür olması beklenir
User prompt
Aşağıdaki güncellenmiş endGame() fonksiyonunu kullanmayı deneyin. Bu versiyonda: Ölüm anında karakterin velocityY değeri, normal (veya düşüşü simüle eden) pozitif bir değer (örneğin 5) olarak ayarlandı. Karakterin update fonksiyonunu geçici olarak override etmek yerine, mevcut update fonksiyonunun normal çalışmasına izin veriyoruz. Böylece gravity, normal şekilde artmaya devam eder. js Kopyala Düzenle function endGame() { LK.effects.flashScreen(0xFF0000, 500); // Ölüm animasyonu için karakterin düşmeye başlaması: // jumpStrength yerine, düşüşü başlatacak pozitif bir hız veriyoruz. character.velocityY = 5; // Karakterin update fonksiyonunu override etmiyoruz; // böylece karakterin normal update() fonksiyonu gravity ekleyerek çalışmaya devam eder. // Tüm yatay hareket yapan objelerin hızını sıfırlıyoruz game.children.forEach(function (child) { if (child.velocityX) { child.velocityX = 0; } }); game.touchDisabled = true; lastScore = passCounter; 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; // Menü animasyonunu yeniden başlatıyoruz var startY = groundY + 100; var endY = centerY() - 1270; 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(); }, 1750); } Açıklamalar: Ölüm anında character.velocityY değerini character.jumpStrength (yani -12) yerine 5 olarak ayarladık. Bu, karakterin yukarı zıplamak yerine, gravity’nin etkisiyle yavaşça düşmesini sağlar. endGame fonksiyonunda karakterin update fonksiyonunu yeniden tanımlamıyoruz; bu sayede, yeni oluşturulan update fonksiyonu gravity ekleyip karakteri düşürmeye devam eder. ResetGame() fonksiyonu, yeni bir karakter yaratıp orijinal gravity/jumpStrength değerlerini (0.3 ve -12) atıyor.
User prompt
1. Tüm Oyun Öğelerini Bir Konteynerde Toplama Öncelikle, oyunun arka planı, karakter, yer, ağaçlar, tüpler gibi öğeleri barındıracak bir worldContainer oluşturun. Örneğin: // Yeni bir konteyner oluşturuyoruz var worldContainer = new Container(); // Oyun öğelerini worldContainer'a ekleyin: worldContainer.addChild(background); worldContainer.addChild(sky); worldContainer.addChild(groundAsset); worldContainer.addChild(ground2Asset); worldContainer.addChild(character); // Diğer oyun öğelerini de ekleyin (örneğin tüpler, ağaçlar vs.) // Ardından worldContainer'ı ana game container'a ekleyin: game.addChild(worldContainer); 2. Zoom Efektini Konteyner Üzerinden Uygulama Daha sonra, kameranın zoom in/out efektini simüle etmek için worldContainer’ın scale değerini değiştiren bir fonksiyon yazabilirsiniz. Örneğin: function zoomEffect() { var originalScale = worldContainer.scale.x; // Başlangıç scale değeri var zoomAmount = 1.2; // Yakınlaştırma miktarı: %20 artış var duration = 150; // Zoom in süresi (ms) var stepTime = 10; // Güncelleme aralığı (ms) var steps = duration / stepTime; var stepSize = (zoomAmount - originalScale) / steps; let stepCount = 0; let zoomIn = setInterval(() => { if (stepCount >= steps) { clearInterval(zoomIn); setTimeout(() => { // Zoom Out işlemi: scale'i orijinal değere getir let zoomOut = setInterval(() => { if (stepCount <= 0) { clearInterval(zoomOut); } else { worldContainer.scale.x -= stepSize; worldContainer.scale.y -= stepSize; stepCount--; } }, stepTime); }, stepTime); } else { worldContainer.scale.x += stepSize; worldContainer.scale.y += stepSize; stepCount++; } }, stepTime); } Bu fonksiyon, worldContainer'ın scale'ini kademeli olarak artırıp sonra orijinal değerine döndürecek; böylece zoom in ve zoom out efekti elde edeceksiniz. 3. Flip/Unflip Fonksiyonlarını Güncelleme Flip işlemlerinde de artık doğrudan kamera yerine worldContainer'ın scale'ini etkilemek isteyeceksiniz. Örneğin: // Dünyayı ters döndürme (flip) fonksiyonu – 0.3 saniye boyunca jump/gravity sıfırlanır function flipWorld() { if (flipped) return; flipped = true; // Karakter etkilerini geçici sıfırla character.gravity = 0; character.jumpStrength = 0; zoomEffect(); // Kamera zoom efekti çalıştır (worldContainer üzerinde) setTimeout(function () { // Ters dünyada: gravity -0.3, jumpStrength 12 character.gravity = -0.3; character.jumpStrength = 12; }, 300); // Dünya elemanlarını ters çevir background.scale.y *= -1; sky.scale.y *= -1; groundAsset.scale.y *= -1; ground2Asset.scale.y *= -1; // Eğer worldContainer içindeki diğer öğeler de flip edilmeli ise onları da burada döndürün. } // Dünyayı eski hâline döndürme (unflip) fonksiyonu – 0.3 saniye boyunca jump/gravity sıfırlanır function unflipWorld() { if (!flipped) return; flipped = false; character.gravity = 0; character.jumpStrength = 0; zoomEffect(); // Kamera zoom efekti çalıştır (worldContainer üzerinde) setTimeout(function () { // Normal dünyada: gravity 0.3, jumpStrength -12 character.gravity = 0.3; character.jumpStrength = -12; }, 300); // Dünya elemanlarını yeniden ters çevirerek orijinal haline döndür background.scale.y *= -1; sky.scale.y *= -1; groundAsset.scale.y *= -1; ground2Asset.scale.y *= -1; // Diğer öğeler de aynı şekilde döndürülmeli. } Özet Doğrudan kamera zoom’u desteklenmediği için: Tüm oyun öğelerini içeren bir worldContainer oluşturun. Zoom efektini simüle etmek için: worldContainer.scale değerini kademeli olarak değiştirin. Flip/unflip fonksiyonlarında: Artık kamera yerine worldContainer üzerinden zoom efektini uygulayın.
User prompt
Please fix the bug: 'ReferenceError: tween is not defined' in or related to this line: 'tween(camera.scale, {' Line Number: 225 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'ReferenceError: camera is not defined' in or related to this line: 'var originalScale = camera.scale.x; // Mevcut zoom seviyesi' Line Number: 222
User prompt
Anladım, karakterin büyümesi yerine kameranın ekrana yaklaşmasını (Zoom In) ve ardından geri eski hâline dönmesini (Zoom Out) istiyorsun. Bunu yapmak için kameranın scale veya position değerleri değiştirilebilir. Aşağıdaki kod, kamerayı 0.3 saniye boyunca yaklaştırıp ardından eski konumuna döndüren bir zoomEffect() fonksiyonu içeriyor: js Kopyala Düzenle // Kameraya 0.3 saniyelik zoom in-out efekti uygulayan fonksiyon function zoomEffect() { var originalScale = camera.scale.x; // Mevcut zoom seviyesi var zoomAmount = 1.2; // %20 yakınlaştır // Zoom In: Kamera ekrana yaklaşsın LK.tween(camera.scale) .to({ x: originalScale * zoomAmount, y: originalScale * zoomAmount }, 150) // 0.15 saniye içinde büyüt .onComplete(function () { // Zoom Out: Kamera eski hâline dönsün LK.tween(camera.scale) .to({ x: originalScale, y: originalScale }, 150) // 0.15 saniye içinde geri dön .start(); }) .start(); } // Dünyayı ters döndürme (flip) fonksiyonu – 0.3 saniye boyunca jump/gravity sıfırlanır function flipWorld() { if (flipped) return; flipped = true; // 0.3 saniye boyunca karakterin jump ve gravity etkilerini devre dışı bırak character.gravity = 0; character.jumpStrength = 0; zoomEffect(); // Kamera zoom efekti çalıştır LK.setTimeout(function () { character.gravity = -0.3; character.jumpStrength = 12; }, 300); // Dünya elemanlarını ters çevir background.scale.y *= -1; sky.scale.y *= -1; groundAsset.scale.y *= -1; ground2Asset.scale.y *= -1; } // Dünyayı eski hâline döndürme (unflip) fonksiyonu – 0.3 saniye boyunca jump/gravity sıfırlanır function unflipWorld() { if (!flipped) return; flipped = false; character.gravity = 0; character.jumpStrength = 0; zoomEffect(); // Kamera zoom efekti çalıştır LK.setTimeout(function () { character.gravity = 0.3; character.jumpStrength = -12; }, 300); // Dünya elemanlarını eski hâline döndür background.scale.y *= -1; sky.scale.y *= -1; groundAsset.scale.y *= -1; ground2Asset.scale.y *= -1; } Açıklamalar: zoomEffect(): Kamera 0.15 saniyede ekrana yaklaşır (Zoom In). Sonrasında 0.15 saniyede eski hâline döner (Zoom Out). Toplam efekt süresi 0.3 saniye olur. Kullanılan Teknoloji: LK.tween() fonksiyonu kamera ölçeğini (scale) değiştirerek zoom efekti yaratır. Alternatif olarak kamera pozisyonunu (position) değiştirmek de mümkün. Flip sırasında kamera zoom yapar: flipWorld() ve unflipWorld() fonksiyonlarında zoomEffect() çağrılır. Böylece her "dünya değiştirme" sırasında zoom efekti çalışır. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Aşağıdaki kod parçasında, 0.3 saniyelik (300ms) efekt süresi için gerekli değişiklikler yapıldı. Hem zoomEffect() fonksiyonunda hem de flipWorld() ve unflipWorld() fonksiyonlarında 200ms yerine 300ms kullanılıyor: js Kopyala Düzenle // Karaktere 0.3 saniyelik (300ms) zoom in-out efekti uygulayan fonksiyon function zoomEffect() { // Mevcut scale değeri (örneğin orijinal 1) var originalScale = character.scale.x; // Zoom in: %20 artış character.scale.set(originalScale * 1.2); // 300ms sonra zoom out yap, orijinal scale'e dön LK.setTimeout(function () { character.scale.set(originalScale); }, 300); } // Dünyayı ters döndürme (flip) fonksiyonu – 0.3 saniye boyunca jump/gravity devre dışı function flipWorld() { if (flipped) return; flipped = true; // 0.3 saniye boyunca karakterin jump ve gravity etkilerini devre dışı bırak character.gravity = 0; character.jumpStrength = 0; zoomEffect(); LK.setTimeout(function () { // Ters dünyada: gravity -0.3, jumpStrength 12 character.gravity = -0.3; character.jumpStrength = 12; }, 300); // Dünya elemanlarını ters çevir (sadece scale yöntemiyle) background.scale.y *= -1; sky.scale.y *= -1; groundAsset.scale.y *= -1; ground2Asset.scale.y *= -1; } // Dünyayı eski hâline döndürme (unflip) fonksiyonu – 0.3 saniye boyunca jump/gravity devre dışı function unflipWorld() { if (!flipped) return; flipped = false; character.gravity = 0; character.jumpStrength = 0; zoomEffect(); LK.setTimeout(function () { // Normal dünyada: gravity 0.3, jumpStrength -12 character.gravity = 0.3; character.jumpStrength = -12; }, 300); // Dünya elemanlarını yeniden ters çevirerek orijinal haline döndür background.scale.y *= -1; sky.scale.y *= -1; groundAsset.scale.y *= -1; ground2Asset.scale.y *= -1; } Bu değişikliklerle: Zoom in/zoom out efekti 300ms sürer. FlipWorld() ve unflipWorld() fonksiyonlarında karakterin jump ve gravity değerleri 300ms süreyle sıfırlanır, ardından flip durumuna göre (ters dünyada: gravity = –0.3, jumpStrength = 12; normal dünyada: gravity = 0.3, jumpStrength = –12) ayarlanır.
Code edit (1 edits merged)
Please save this source code
User prompt
5. skorda ekran ters dönsün 10. skorda ilk haline dönsün
Code edit (1 edits merged)
Please save this source code
/**** * 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; updateScore(); } } }; 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; updateScore(); } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Karaktere 0.2 saniyelik (200ms) zoom in-out efekti uygulayan fonksiyon function zoomEffect() { // Mevcut scale değeri (örneğin orijinal 1) var originalScale = character.scale.x; // Zoom in: %20 artış character.scale.set(originalScale * 1.2); // 300ms sonra zoom out yap, orijinal scale'e dön LK.setTimeout(function () { character.scale.set(originalScale); }, 300); } // Dünyayı ters döndürme (flip) fonksiyonu – 0.2 saniye boyunca jump/gravity devre dışı function flipWorld() { if (flipped) { return; } flipped = true; // 0.3 saniye boyunca karakterin jump ve gravity etkilerini devre dışı bırak character.gravity = 0; character.jumpStrength = 0; zoomEffect(); LK.setTimeout(function () { // Ters dünyada: gravity -0.3, jumpStrength 12 character.gravity = -0.3; character.jumpStrength = 12; }, 300); // Dünya elemanlarını ters çevir (sadece scale yöntemiyle) background.scale.y *= -1; sky.scale.y *= -1; groundAsset.scale.y *= -1; ground2Asset.scale.y *= -1; } // Dünyayı eski hâline döndürme (unflip) fonksiyonu – 0.2 saniye boyunca jump/gravity devre dışı function unflipWorld() { if (!flipped) { return; } flipped = false; character.gravity = 0; character.jumpStrength = 0; zoomEffect(); LK.setTimeout(function () { // Normal dünyada: gravity 0.3, jumpStrength -12 character.gravity = 0.3; character.jumpStrength = -12; }, 300); // Dünya elemanlarını yeniden ters çevirerek orijinal haline döndür background.scale.y *= -1; sky.scale.y *= -1; groundAsset.scale.y *= -1; ground2Asset.scale.y *= -1; } // Skoru güncelleme fonksiyonu – Her 5 skorda flip/unflip toggle function updateScore() { passCounter++; counterText.setText(passCounter); if (passCounter % 5 === 0) { if (!flipped) { flipWorld(); } else { unflipWorld(); } } } /**** * 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 // Flip durumunu takip eden bayrak var flipped = false; 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() + 205 }); playButton.visible = false; menuContainer.addChild(playButton); var playLabel = new Text2("PLAY", { fontFamily: "Arial", fontSize: 630.25 * 1.1 * 1.08, fill: 0xffffff }); playLabel.anchorX = 0.5; playLabel.anchorY = 0.5; playLabel.x = playButton.x - 45; playLabel.y = playButton.y - -25; playLabel.visible = true; playLabel.zIndex = 1000; menuContainer.addChild(playLabel); // VOLUME var volumeButton = LK.getAsset('button_volume', { anchorX: 0.5, anchorY: 0.5, x: centerX() - 28, y: centerY() + 310 }); volumeButton.visible = false; menuContainer.addChild(volumeButton); var volumeLabel = new Text2("VOLUME", { fontFamily: "Arial", fontSize: 63.25 * 1.1 * 1.05 * 1.05 * 1.05, fill: 0xffffff }); volumeLabel.anchorX = 0.5; volumeLabel.anchorY = 0.5; volumeLabel.x = volumeButton.x - 58; volumeLabel.y = volumeButton.y + 30; 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, fill: 0xffffff }); creditsLabel.anchorX = 0.5; creditsLabel.anchorY = 0.5; creditsLabel.x = creditsButton.x - 60; creditsLabel.y = creditsButton.y + 28; 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, fill: 0xffffff }); recordsLabel.anchorX = 0.5; recordsLabel.anchorY = 0.5; recordsLabel.x = recordsButton.x - 67; recordsLabel.y = recordsButton.y + 28; recordsLabel.visible = true; recordsLabel.zIndex = 1000; menuContainer.addChild(recordsLabel); // Ekranda sayacımız var counterText = new Text2('0', { size: 124.2, 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) { var closeLabel = new Text2("X", { fontFamily: "Arial", fontSize: Math.round(350000 * 10000.16 * 10000.15), fill: 0xffffff, align: "center" }); closeLabel.anchorX = 0.5; closeLabel.anchorY = 0.5; closeLabel.zIndex = 10000; closeLabel.x = centerX() + modalWidth / 2 - 0; closeLabel.y = 350; var radius = 50; var closeButton = LK.getAsset('button_close', { anchorX: 1.85, anchorY: -1.10, width: radius * 2.3 * 1.2, height: radius * 2.3 * 1.2 }); closeButton.zIndex = 10000; closeButton.x = closeLabel.x + 0; closeButton.y = closeLabel.y + 0; closeButton.addChild(closeLabel); return { closeLabel: closeLabel, closeButton: closeButton }; } function showCredits() { var creditsContainer = new Container(); creditsContainer.zIndex = 300; var modalWidth = 1250, modalHeight = 2000; var bg = LK.getAsset('second_menu', { 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 + 40; creditsText.scale.set(3, 3); creditsContainer.addChild(creditsText); 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; var modalWidth = 1250, modalHeight = 2000; var bg = LK.getAsset('second_menu', { 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 + 40; volumeContainer.addChild(volumeText); 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('second_menu', { 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 + 40; 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; } } }; game.children.forEach(function (child) { if (child.velocityX) { child.velocityX = 0; } }); game.touchDisabled = true; lastScore = passCounter; 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; var endY = centerY() - 1270; 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(); }, 1750); } function resetGame() { if (gameOverText) { game.removeChild(gameOverText); gameOverText = null; } // Flip'i eski hâline döndür unflipWorld(); 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) { var scaleFactorX = 1; var scaleFactorY = 0.53; var offsetY = 40; var dx = lx - button.x; var dy = ly - (button.y + offsetY); var rx = button.width / 2 * scaleFactorX; var ry = button.height / 2 * scaleFactorY; return dx * dx / (rx * rx) + dy * dy / (ry * ry) <= 1; } /**** * Fare hareketinde hover kontrolü ****/ game.move = function (x, y, obj) { var localX = x - menuContainer.x; var localY = y - menuContainer.y; 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) { var localX = x - menuContainer.x; var localY = y - menuContainer.y; if (checkEllipseHover(playButton, localX, localY)) { 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) { gameWait = false; gameStarted = true; var initialTube = new Tube(); game.addChild(initialTube); lastSpawner = initialTube; character.jump(); } else { 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
@@ -202,28 +202,28 @@
// Mevcut scale değeri (örneğin orijinal 1)
var originalScale = character.scale.x;
// Zoom in: %20 artış
character.scale.set(originalScale * 1.2);
- // 200ms sonra zoom out yap, orijinal scale'e dön
+ // 300ms sonra zoom out yap, orijinal scale'e dön
LK.setTimeout(function () {
character.scale.set(originalScale);
- }, 200);
+ }, 300);
}
// Dünyayı ters döndürme (flip) fonksiyonu – 0.2 saniye boyunca jump/gravity devre dışı
function flipWorld() {
if (flipped) {
return;
}
flipped = true;
- // 0.2 saniye boyunca karakterin jump ve gravity etkilerini devre dışı bırak
+ // 0.3 saniye boyunca karakterin jump ve gravity etkilerini devre dışı bırak
character.gravity = 0;
character.jumpStrength = 0;
zoomEffect();
LK.setTimeout(function () {
// Ters dünyada: gravity -0.3, jumpStrength 12
character.gravity = -0.3;
character.jumpStrength = 12;
- }, 200);
+ }, 300);
// Dünya elemanlarını ters çevir (sadece scale yöntemiyle)
background.scale.y *= -1;
sky.scale.y *= -1;
groundAsset.scale.y *= -1;
@@ -241,9 +241,9 @@
LK.setTimeout(function () {
// Normal dünyada: gravity 0.3, jumpStrength -12
character.gravity = 0.3;
character.jumpStrength = -12;
- }, 200);
+ }, 300);
// Dünya elemanlarını yeniden ters çevirerek orijinal haline döndür
background.scale.y *= -1;
sky.scale.y *= -1;
groundAsset.scale.y *= -1;