lukaMis Posted July 7, 2014 Share Posted July 7, 2014 Hi I have a question regarding starting State with custom parameter. From docs i see:start(key, clearWorld, clearCache, parameter)Start the given State. * Additional parameters that will be passed to the State.init function (if it has one). There is no init method in State. If i make one in my state will it get called or not? Will init be called before create? Reason i am asking is that i would like to start state PlayGame with one of these params ['L1', 'L2', 'L3', 'L4' ].Param will depend on what button user clicks in LevelSelect menu. TnxLuka Link to comment Share on other sites More sharing options...
eguneys Posted July 7, 2014 Share Posted July 7, 2014 Yes first init gets called, then create, then update, and function MyState() {} MyState.prototype = { // State init method gets the params here init: function(params) { }, create: function() { var params = ['L1', 'L2']; // you start a new state with parameter like this this.game.state.start('my-state', true, false, params); }, update: function() { } };Here is a list of other methods you can define in your state:http://www.html5gamedevs.com/topic/1372-phaser-function-order-reserved-names-and-special-uses/Note: I think init method should be mentioned there as well. arialblack14 1 Link to comment Share on other sites More sharing options...
Recommended Posts