PRSoluções Posted March 30, 2016 Share Posted March 30, 2016 Hi, My game has this flow: [boot] -> [title] -> [game] -> [title] The problem is when i go from [game] to [title]. I think it still with game properties (camera, etc...). Has a "phaser native" way to reset it? Thanks. [Images with the problem] Link to comment Share on other sites More sharing options...
PRSoluções Posted March 30, 2016 Author Share Posted March 30, 2016 I solve it with: game.world.setBounds(, , game.width, game.height); This is the correct way? Or have a native reset method? Link to comment Share on other sites More sharing options...
PRSoluções Posted March 30, 2016 Author Share Posted March 30, 2016 Another problem is the GameState properties. When TitleState send me to GameState the previous properties remain o.o and the player is duplicated. Look: 1 - When my code call GameState.init i execute: console.log(this.players); this.players = {}; this.player = null; console.log(this.players); The first time on console: undefined and {} Backing to title and going to game again, on console: Object {} and Object {} Too strange. Link to comment Share on other sites More sharing options...
megmut Posted April 1, 2016 Share Posted April 1, 2016 Two things, one this may be caching issue, see here to clear cache on state change: http://phaser.io/docs/2.4.4/Phaser.StateManager.html#start What I think is the actual issue, just looking briefly at your code, is when you set this.players inside a state, you set that object up inside the state object. you could set this back to null on the shutdown method, provided by phaser states, that gets called when the state is ended. i.e: init() { this.players = {}; } create() { } update() { } shutdown() { this.players = null; } Link to comment Share on other sites More sharing options...
Recommended Posts