I’m a bit confused on how to structure a Phaser 3 game.
Ideally I’d like to have a Main() class. Then in this main class, I can call different scenes Intro(), LevelOne(), LevelTwo(), Credits(), etc.
Right now I’ve been following tutorials and my config is like this:
var config = {
type: Phaser.AUTO,
width: 1520,
height: 720,
_resolution: window.devicePixelRatio,
resolution: 2,
physics: {
default: ‘arcade’,
arcade: {
gravity: { y: 200 }
}
},
scene: [Level_1, Level_2]
};
But I’m confused on how I change from Level 1 to Level 2 and control the logic and flow of my game. I’m making a 2D platformer/RPG.
I tried making a Main class like so, but Phaser 3 gave me an error that “preload is undefined”
class Main extends Phaser.Game{
constructor(){ super(config); var config = { type: Phaser.AUTO, width: 1520, height: 720, _resolution: window.devicePixelRatio, resolution: 2, physics: { default: 'arcade', arcade: { gravity: { y: 200 } } }, scene: { preload: preload, create: create, update: update } }; } preload(){ } create(){ } update(){ }
}
Please help