Search the Community
Showing results for tags 'global state'.
Found 1 result
Phaser global state object
DanielDunderfelt posted a topic in Phaser 2Hello Phaserists! I just started out with Phaser, and was wondering if there's a built-in way to have a global state object. What I mean is an object whose preload, update, create and render methods are always called, regardless of which other state the game is currently in. I've solved it by having a singleton object with the needed methods, which I always import into my state files (I use ES6). Then I can call its methods from the respective methods of the real state. While this solution isn't bad, it would be useful to have a built-in way to declare a global state object, maybe something like game.setGlobalState(myStateObject)// ornew Phaser.Game(..., myStateObject)Something to consider?