Phaser 3 ScaleManager 异常
Phaser 3 ScaleManager exception
我正在尝试在用 Phaser 3 编写的游戏中启用全屏。
我是从 Scene
class 通过
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)
...
在docsScaleManager
class中有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);
}
}
有两个问题阻止我解决这个问题:
我遵循了这里的例子
https://www.phaser.io/examples/v2
不过我用的是第三版Phaser。每个使用它的人都必须遵循这里的例子
https://www.phaser.io/examples/v3
在使用带有示例的网站时,您必须注意 url。乍一看,这两个页面是一样的。但是 urls 是不同的。在使用第二(旧)版本引擎的每个示例后也有警告。
最后这个函数名不是startFullScreen
而是startFullscreen
:)
我正在尝试在用 Phaser 3 编写的游戏中启用全屏。
我是从 Scene
class 通过
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)
...
在docsScaleManager
class中有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);
}
}
有两个问题阻止我解决这个问题:
我遵循了这里的例子
https://www.phaser.io/examples/v2
不过我用的是第三版Phaser。每个使用它的人都必须遵循这里的例子
https://www.phaser.io/examples/v3
在使用带有示例的网站时,您必须注意 url。乍一看,这两个页面是一样的。但是 urls 是不同的。在使用第二(旧)版本引擎的每个示例后也有警告。
最后这个函数名不是
startFullScreen
而是startFullscreen
:)