Untitled
const app = new PIXI.Application({ width: window.innerWidth, height: window.innerHeight, backgroundColor: 0x1099bb, }); document.body.appendChild(app.view); // Ekran yönünü kontrol eden fonksiyon function checkOrientation() { const isLandscape = window.innerWidth > window.innerHeight; // Ekran boyutlarını yeniden ayarla app.renderer.resize(window.innerWidth, window.innerHeight); // Mesaj göster if (isLandscape) { console.log("Ekran yatay modda."); displayMessage("Yatay Mod", app.renderer.width / 2, app.renderer.height / 2); } else { console.log("Ekran dikey modda."); displayMessage("Dikey Mod", app.renderer.width / 2, app.renderer.height / 2); } } // Mesajı gösteren basit bir fonksiyon let message; function displayMessage(text, x, y) { if (message) app.stage.removeChild(message); // Önceki mesajı kaldır const style = new PIXI.TextStyle({ fontSize: 36, fill: '#ffffff', }); message = new PIXI.Text(text, style); message.anchor.set(0.5); message.x = x; message.y = y; app.stage.addChild(message); } // İlk yön kontrolü checkOrientation(); // Yön değişikliğini algılamak için resize olayını dinle window.addEventListener('resize', checkOrientation);
Leave a Comment