phaser
phaser copied to clipboard
node + `Phaser.HEADLESS` --> `(Phaser.Scene).add` function does not add new scene
Version
- Phaser Version: Phaser v3.55.2-FB (Headless | No Audio)
- Operating system: Windows 10
- Browser: $ node v14.17.6
Description
Using node + Phaser.HEADLESS
, (Phaser.Scene).add
function does not add new scene. The associated constructor
, init
, preload
, create
, and update
functions also do not run. Changing the Phaser.Game
type
to Phaser.CANVAS
makes the associated functions run correctly.
Example Test Code
class MainScene extends Phaser.Scene {
constructor(config) {
super(config)
}
create() {
const dynamicSceneName = `dynamicSceneName${Phaser.Math.Between(0, 9999999)}`
console.log(`Adding ${dynamicSceneName}...`)
this.scene.add(dynamicSceneName, SomeDynamicScene, true)
}
}
class SomeDynamicScene extends Phaser.Scene {
constructor(config) {
super(config)
console.log(`config:`, config) // THIS DOES NOT GET CALLED ON (NODE + `Phaser.HEADLESS`), BUT WORKS ON (NODE + `Phaser.CANVAS`)
}
create() {
console.log(`SomeDynamicScene: create`) // THIS DOES NOT GET CALLED ON (NODE + `Phaser.HEADLESS`), BUT WORKS ON (NODE + `Phaser.CANVAS`)
}
update(time, deltaTime) {
console.log(`SomeDynamicScene: update`) // THIS DOES NOT GET CALLED ON (NODE + `Phaser.HEADLESS`), BUT WORKS ON (NODE + `Phaser.CANVAS`)
}
}
var config = {
type: Phaser.HEADLESS, // THIS DOES NOT WORK ON NODE (WORKS IN BROWSERS)
// type: Phaser.CANVAS, // THIS WORKS ON NODE
scene: [
MainScene
]
}
var game = new Phaser.Game(config)
Additional Information
phaser: 3.55.2 webpack 4.29.0 ts-node 9.1.1 ts-loader: 5.3.3 node: 14.16.0
Check if MainScene#update()
gets called.
MainScene#create()
and MainScene#update()
gets called correctly (with either Phaser.HEADLESS
or Phaser.CANVAS
on node).
Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master
branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.