移相器3打字稿错误游戏未绑定

时间:2019-01-30 05:14:44

标签: javascript phaser-framework

到目前为止,我已经尝试使用Typescript绑定简单地启动Phaser 3游戏。下面是我的main.js入口点。

/**@type {import("../typings/phaser")} */
let config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600
};
let game = Phaser.Game(config);

我使用的是我认为是phaser.d.ts中最新的打字稿定义。但是,在加载游戏时,出现以下错误。

phaser.min.js:1 Uncaught TypeError: Cannot read property 'bind' of undefined
    at Object.initialize [as Game] (phaser.min.js:1)
    at Object.parcelRequire.src/main.js (main.js:7)
    at newRequire (main.1e43358e.js:49)
    at main.1e43358e.js:81
    at main.1e43358e.js:107

1 个答案:

答案 0 :(得分:1)

Phaser.Game是构造函数,需要使用关键字new

let game = new Phaser.Game(config);