Mike018 Posted July 13, 2017 Share Posted July 13, 2017 When I have many objects always referencing the game and the game height, it is better to create my own variables at the beginning and reference them or keep using the in-game variables? Not sure if it stores everything after the first time. this.game; this.game.world.height; or this.game_ = this.game; this.gameHeight_ = this.game.world.height; Link to comment Share on other sites More sharing options...
Beyb26 Posted July 13, 2017 Share Posted July 13, 2017 The second one is better. Link to comment Share on other sites More sharing options...
Skeptron Posted July 13, 2017 Share Posted July 13, 2017 I'd better always use this.game.world.height, as it may vary. With your second option, you will have the height value at the time you create your variable, but if later on the game is resized the value will no longer be accurate, whereas this.game.world.height will always be correct. Juan 1 Link to comment Share on other sites More sharing options...
Recommended Posts