document.addEventListener(“DOMContentLoaded”, function () { const gameContainer = document.getElementById(“gameContainer”); const fullscreenBtn = document.getElementById(“fullscreenBtn”); const iframe = document.getElementById(“embededGame”); // Hàm kích hoạt fullscreen trên mọi thiết bị function enterFullscreen() { if (gameContainer.requestFullscreen) { gameContainer.requestFullscreen(); } else if (gameContainer.mozRequestFullScreen) { // Firefox gameContainer.mozRequestFullScreen(); } else if (gameContainer.webkitRequestFullscreen) { // Chrome, Safari, iOS gameContainer.webkitRequestFullscreen(); } else if (gameContainer.msRequestFullscreen) { // IE/Edge gameContainer.msRequestFullscreen(); } } // Thoát fullscreen khi cần function exitFullscreen() { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.mozCancelFullScreen) { // Firefox document.mozCancelFullScreen(); } else if (document.webkitExitFullscreen) { // Chrome, Safari, iOS document.webkitExitFullscreen(); } else if (document.msExitFullscreen) { // IE/Edge document.msExitFullscreen(); } } // Sự kiện khi nhấn nút để bật fullscreen fullscreenBtn.addEventListener(“click”, function () { enterFullscreen(); }); // Hỗ trợ tự động fullscreen khi chạm vào màn hình trên điện thoại gameContainer.addEventListener(“touchstart”, function () { if (!document.fullscreenElement) { enterFullscreen(); } }); // Thoát fullscreen khi nhấn ESC trên máy tính document.addEventListener(“keydown”, function (e) { if (e.key === “Escape”) { exitFullscreen(); } }); // Tối ưu hiển thị trên điện thoại khi xoay ngang window.addEventListener(“orientationchange”, function () { setTimeout(() => { if (window.innerHeight > window.innerWidth) { alert(“Vui lòng xoay ngang thiết bị để chơi game tốt hơn!”); } }, 500); }); });

4 bình luận về “Flappy Bird 2.0

Để lại một bình luận

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *