我是使用 Phaser-2.4.4 进行游戏开发的新手。目前我正在开发一款游戏,我需要在浏览器中设置全屏模式。首先我创建一个游戏对象,然后调用全屏方法,它根本不起作用。
var game = new Phaser.Game(1920, 1080, Phaser.AUTO, '', {preload : preload,create :create, update : update});
game.scale.startFullScreen();
错误是
Failed to execute 'requestFullScreen' on 'Element': API can only be initiated by a user gesture.
Phaser.ScaleManager: requestFullscreen failed or device does not support the Fullscreen API
请帮助并让我知道我缺少什么。
最佳答案
这只是因为没有用户交互就无法触发全屏。实际上说“全屏显示”的代码片段必须是用户单击某些内容(任何内容)的结果。
这是浏览器限制,而不是 Phaser 问题。
我建议遵循标准做法并放置一个“全屏”按钮,以便用户有选择
关于javascript - StartFullScreen() 方法无法使用 Phaser-2.4.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33307908/