Keenic Posted April 13, 2016 Share Posted April 13, 2016 Hi, I'm creating a game restart and after change state text won't appear. Code to create text: this.game.add.text(45, 220, '0', {fill: '#fff'}); And after that, this text show on state but when i change state by this.state.start('Start'); the text just diseappear. Link to comment Share on other sites More sharing options...
drhayes Posted April 13, 2016 Share Posted April 13, 2016 The second parameter to StateManager.start (the method you're calling there) is "clearWorld". It defaults to true. If you don't want the text to disappear, you can either pass "false" as the next argument to start, or you can add the text directly to the stage ("game.stage.add(this.game.make.text(..."). Link to comment Share on other sites More sharing options...
Keenic Posted April 14, 2016 Author Share Posted April 14, 2016 It helped with text but now in buttons place is clickable area. I disable it by kill the buttons but is there any other way to do it properly? Link to comment Share on other sites More sharing options...
drhayes Posted April 14, 2016 Share Posted April 14, 2016 Well, if you were depending on clearing the world to remove the buttons but now you're not clearing the world... sounds like you have to get rid of the buttons yourself somehow. Maybe in the shutdown method of the state you're leaving? Link to comment Share on other sites More sharing options...
Keenic Posted April 15, 2016 Author Share Posted April 15, 2016 I wasn't aware of this, I just change the state by state.start(). Before state change should I destroy everything for better performance? Link to comment Share on other sites More sharing options...
drhayes Posted April 15, 2016 Share Posted April 15, 2016 I don't worry about performance until performance is worth worrying about. If you're seeing performance problems start fixing them. Before then, you're guessing where the problem is... and it's probably *way* more fun to work on your actual game. I *am* careful about unsubscribing my signals, but that's mostly because it causes bugs when you're on the main menu and you still have the spacebar trying to make the player jump, for example. Link to comment Share on other sites More sharing options...
Recommended Posts