Jump to content

Trying to load stages: Invalid Phaser State object given


killer_manatee
 Share

Recommended Posts

Hello. I'm trying to refactor my code into multiple files and create various stages. Here's how I do it: 

// game.js

var bootState = require('./boot');
var loadState = require('./load');


var mygame = new Phaser.Game(800, 600, Phaser.AUTO);

mygame.state.add('boot', bootState);
mygame.state.start('boot');

export  {mygame};

//boot.js

import { mygame } from './game.js';


var bootState = {
  create() {
    mygame.physics.startSystem(Phaser.Physics.ARCADE);
  }
};

export {bootState};

I've also tried changing boot.js to 

import { mygame } from './game.js';


var bootState = {

  create: function() {
    mygame.physics.startSystem(Phaser.Physics.ARCADE);
    mygame.state.start('load');
  }
};

export {bootState};

but that doesn't work either. I'm getting 'Invalid Phaser State object given. Must contain at least a one of the required functions: preload, create, update or render'. 

 

Thanks

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...