xronn Posted February 10, 2014 Share Posted February 10, 2014 Hi, So I have one level in a js file and another level in another js file;level1.jslevel2.jsThe great guys in the chat room say I need to use states to manage switching between levels, but I havent seen any examples or tutorials on this. Would I just let my first level load then when player overlaps tile X run some function that uses the state function to load level2.js. Thanks! Link to comment Share on other sites More sharing options...
jerome Posted February 11, 2014 Share Posted February 11, 2014 tuto : http://s-nambiar.com/tutorials/managing-game-states-phaser/doc : https://github.com/photonstorm/phaser/wiki/Phaser-General-Documentation-:-Statestemplate : https://github.com/photonstorm/phaser/tree/master/resources/Project%20Templates/Basic Teemu-Tor 1 Link to comment Share on other sites More sharing options...
xronn Posted February 11, 2014 Author Share Posted February 11, 2014 Thanks, that template is really useful I know a few others are looking for this so hope it helps anyone else! Link to comment Share on other sites More sharing options...
xronn Posted February 12, 2014 Author Share Posted February 12, 2014 Sorry for double post I didn't want to open a new thread, I'm having trouble loading a new state when you click an image (play button);I have this currently;this.add.sprite(170, 170, 'playBtn', this.startGame);Then my game.js file startsBasicGame.Game = function (game) {My game state is:game.state.add('Game', BasicGame.Game); Link to comment Share on other sites More sharing options...
jerome Posted February 12, 2014 Share Posted February 12, 2014 what's the error in the javascript console of your browser ?state.add(key, stateObject) doesn't start the state, it only adds it to the game.. the state object must exist in the code before being openedstate.start(key) does start it Link to comment Share on other sites More sharing options...
Hsaka Posted February 12, 2014 Share Posted February 12, 2014 Hi, you can use a button instead of a sprite:this.add.button(170, 170, 'playBtn', this.startGame, this); Link to comment Share on other sites More sharing options...
xronn Posted February 12, 2014 Author Share Posted February 12, 2014 Thanks, I changed it to a button! Link to comment Share on other sites More sharing options...
Recommended Posts