missionz3r0 Posted August 10, 2015 Share Posted August 10, 2015 Just trying to change the game state on a timer event. Currently working withthis.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 More sharing options...
maximilianoo Posted December 23, 2015 Share Posted December 23, 2015 Hello, I have not tested this, but I think the arguments parameter should be an Array. Like this:this.time.events.add(3000, this.state.start, this, ['state_name']);Reference: http://phaser.io/docs/2.4.4/Phaser.Timer.html#add arguments * <repeatable> Additional arguments that will be supplied to the callback. Link to comment Share on other sites More sharing options...
shnfara Posted March 30, 2016 Share Posted March 30, 2016 (edited) BUMP 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? EDIT: 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.state.start(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 March 30, 2016 by shnfara found a solution Link to comment Share on other sites More sharing options...
Recommended Posts