Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Changing state on timer


Recommended Posts

Just trying to change the game state on a timer event.


Currently working with

this.time.events.add(3000, this.state.start, this, 'state_name');

in a logo state I wanted to stay around for three seconds before starting up the next state. The events goes off, but the function doesn't execute. Giving back "Uncaught TypeError: this.checkState is not a function". 


Any suggestions on how to get around this, and any idea what's going on under the hood to cause this?

Link to comment
Share on other sites

  • 4 months later...
  • 3 months later...


Also getting this error... whether I use an array or not to pass the argument. Also doesn't matter if we make the call in a time event or onComplete call on a tween.

Pretty bogus... any suggestions? missionz3r0 did you figure it out?


so I figured out that you can make another function, put the state change call in it, and call that from the time event with an argument.  Not very elegant...

function changeState(stateID) {

game.time.events.add(1000, changeState, this, 'name_of_my_state');

PS. You don't have to pass arguments as an array, in the docs the asterix * under Type indicates that it can be anything.

Edited by shnfara
found a solution
Link to comment
Share on other sites


  • Recently Browsing   0 members

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