I’m rather new to Phaser and a bit confused with multiple scenes sharing my socket connection. My game currently uses one large Scene class, but I’d like to break it up into a connection, login, main game and editor scene, all of which will need the websocket object.
What would be the best way to handle this? If it matters, this is how I am initializing my game.
const config = {
type: Phaser.AUTO,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
parent: "thegame",
//width: window.innerWidth,
width: 1024,
height: 600,
backgroundColor: '#ffffff',
},
scene: [
GameScene
]
}
class Game extends Phaser.Game {
constructor(config) {
super(config)
}
}
window.addEventListener('load', function () {
let game = new Game(config)
})