zxxz Posted January 31, 2014 Share Posted January 31, 2014 Hello, I have set up a game which uses states as per the template which is working fine. I have registered the event: player.events.onOutOfBounds.add(this.playerOut, this); and have the function:playerOut: function() { this.game.state.start('MainMenu'); },When the player goes out of bounds to the left of the world then the game state successfully changes to the main menu. However, if the player falls through the bottom or the right side of the world then the main menu state does not correctly appear but there is something happening. Is it the way in which I have attempted to do accomplish this which is causing the problem? Also what kind of clean up should I be doing in the playerOut function to clear up resources? Thank you. Link to comment Share on other sites More sharing options...
rich Posted February 1, 2014 Share Posted February 1, 2014 There is nothing wrong with the bit of code above, so something else must be going on / blocking the sprite. Link to comment Share on other sites More sharing options...
Mariusz Posted February 1, 2014 Share Posted February 1, 2014 Also what kind of clean up should I be doing in the playerOut function to clear up resources? I'd also like to know the answer to the question above. Link to comment Share on other sites More sharing options...
jpdev Posted February 1, 2014 Share Posted February 1, 2014 Maybe you are running into a problem similar to mine.For me the solution was in resizing the world to game-size in the create method of the menu-state. (because my tilemap had made it bigger and my button placement was off because of it.) Details here: http://www.html5gamedevs.com/topic/3359-camera-not-positioned-correctly-after-changing-start-away-from-scrolling/?view=findpost&p=22566 Link to comment Share on other sites More sharing options...
zxxz Posted February 1, 2014 Author Share Posted February 1, 2014 Thanks a lot jpdev, your solution fixed it! What kind of clean up should be done before changing the scene back to the main menu? Cheers! Link to comment Share on other sites More sharing options...
Recommended Posts