Jump to content

should you create references to in-game variables?


Mike018
 Share

Recommended Posts

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

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.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...