According to phaser.io/tutorials, you can set a initial preload
/create
function for the game instance:
this.game = new Phaser.Game(800, 600, Phaser.AUTO, 'content', { preload: this.preload, create: this.create });
However, I'm trying to pass these constructor arguments as an object instead:
SceneContainers.phaserGame = new Phaser.Game({
width: ProjectSettings.resolution[0],
height: ProjectSettings.resolution[1],
type: Phaser.AUTO,
parent: 'content',
backgroundColor: ProjectSettings.backgroundColor,
// 'preload: ...' and 'create: ...' do not exist here
// Also, 'callbacks: ...' does not support 'preload: ...' and 'create: ...'
// according to TypeScript completions.
});
To which property does belong preload
/create
? When I look at the API docs, I search for preload
and nothing shows up: Phaser.Game and Phaser.Types.Core.GameConfig.
CodePudding user response:
the short answer is, is the property scene
.
var config = {
...
width: 800,
height: 600,
scene: { preload: this.preload, create: this.create },
...
};
Althought, that property can also be set with other data types.
Minor Update: In this tutorial section, there are several nice examples, on how this property can be used https://phaser.io/examples/v3/category/scenes, I still consult these examples, when I have to write phaser apps/code.