About global variables and array...

0 favourites
  • 2 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • So, I'm listing all the atributes for the player (sprite object), and for now I have 33 global variables referencing the atributes. It seems right, since the player travels through various layouts.

    A friend of mine told me too much global variables can impact performance, and that I should use array to store the values.

    OK, it makes sense, I think.

    BUT if my event for movement is a function like

    Input button is pressed >> Move PlayerSprite (SPEED*2) at angle α

    (with SPEED now being a global variable)

    If I SPEED change it to an array value, it does even make any change? Because the game will have to access the array value every single tick anyways...

    Am I overthinking it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Is it impacting performance though? I've never had a problem with using 'too many' global variables. I think if you have thousands of events you might start to see something. Running through an array every tick sounds worse, like it could be more of a performance drain.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)