我正在尝试在我的游戏中启用全屏功能,我是在Scene类中通过
this.game.scale.startFullScreen();但在f12浏览器控制台中出现错误
Uncaught TypeError: this.game.scale.startFullScreen is not a function
at TitleScene.<anonymous> (TitleScene.js:23)
at InputPlugin.emit (phaser.js:2025)
at InputPlugin.processDownEvents (phaser.js:167273)
...在docs中,ScaleManager类有startFullScreen方法。
为什么控制台告诉我没有?
这是TitleScene.js的完整代码
export class TitleScene extends Phaser.Scene {
constructor ()
{
const config =
{
key: 'TitleScene'
}
super(config);
}
preload ()
{
this.load.image('Title', 'assets/Title.png');
}
create ()
{
this.background = this.add.image(960, 540, 'Title');
this.input.manager.enabled = true;
this.input.once('pointerdown', function () {
this.scene.start('MainScene');
this.game.scale.startFullScreen(); // here is the error
}, this);
}
}发布于 2020-08-13 23:33:09
有两个问题阻碍了我解决这个问题:
https://www.phaser.io/examples/v2
但我使用的是第三个版本的Phaser。使用相同代码的每个人都必须遵循下面的示例
https://www.phaser.io/examples/v3
在使用他们的示例站点时,您必须注意url。两个页面从第一眼看起来都是一样的。但是urls是不同的。此外,在使用engine的第二个(旧)版本的每个示例之后都会出现警告。
startFullScreen,而是startFullscreen :)https://stackoverflow.com/questions/63360552
复制相似问题