In Phaser, how should I be managing state? [closed]

I'm quite new to Phaser and JavaScript really confused about state management.

Phaser has lots of documentation and info on the net, but everyone seems to be doing it a different way.

An example:

var game = new Phaser.Game(800,600, Phaser.AUTO, 'phaser-demo',

function create() { ... }
function update() { ... }
function render() { ... }


Another:

window.game = new Phaser.Game(800, 600, Phaser.AUTO);
// all other states are in different files

module.exports = {
create:  function(){ ... },
update:  function(){ ... }
};


I would be grateful for a simple overview of properly handling states.

• What's wrong with how you're doing things now? What have you tried and what's not working about it?
– House
Mar 5, 2015 at 18:20
• Im just confused because I often run into problems and I believe knowing the right way of doing it would make my development smoother. Mar 5, 2015 at 18:31
• Right, but you need to be a bit more specific about your concerns. "What's the best way" will get you 5 different answers from 5 different people, without one being more correct than the next. Those aren't the types of questions we do here.
– House
Mar 5, 2015 at 18:32
• thanks! Ill rephrase my question to be more precise and understandable. Mar 5, 2015 at 18:33
• Phaser has a State class you can use to build your own states. The whole initialization of phaser then boils down to adding states and starting with one. Maybe this tutorial helps. Mar 5, 2015 at 19:33