How many Global Variables is too much?

0 favourites
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.
  • I am making a 2d platform puzzler. I plan on having over 100 levels. For each level, I need to save the players Best Time, High Score, Deaths, Restarts, etc...

    My question is, how many Global Variables can it handle before slowing down the game?

  • This type of data doesn't belong into global variables. It should saved to a file, and managed as arrays at runtime! You just need to use the AJAX object and to create a text file into the file folder of your construct project.

    Good luck going forward!

    Nathan

  • Are you going to make 100 layouts?

  • Just use an array and save the data locally using Webstorage.

  • This type of data doesn't belong into global variables. It should saved to a file, and managed as arrays at runtime! You just need to use the AJAX object and to create a text file into the file folder of your construct project.

    Good luck going forward!

    Nathan

    Thanks for the info...I will look into AJAX

  • Are you going to make 100 layouts?

    Yes, each one being 1280, 720 in size. You can see the entire level on sceen.

  • Just use an array and save the data locally using Webstorage.

    I used just Webstorage at first, but I was unable to add multiple webstorages values to get a grand total. So I loaded the webstorage values into a global variable to be able to add multiple levels scores together.

  • There's no need for external files. Use Array (or dictionary) to store values and then use webstorage for saving and loading.

  • Thanks for the info everyone. This has saved me precious time and a headache.

  • If you will put a tree in every layout, This will be 100 original tree and the image memory will increase.

    If you have 10 trees in one layout, This will consider one tree in the image memory.

    I don't think it will be a good idea to have 100 layout.

  • I have about 100 global variables (numbers), there's no performance impact. I use GV for saving data as well as for AI triggers or combat.

  • If you will put a tree in every layout, This will be 100 original tree and the image memory will increase.

    If you have 10 trees in one layout, This will consider one tree in the image memory.

    I don't think it will be a good idea to have 100 layout.

    Well I'm not sure why, but when I duplicated a Layout 35 times, my image memory did not increase.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • On the PC, assets are loaded per layout not the entire game.

    C2 has very good native memory management.

  • A0Nasser most export options support memory management so they load only whats on that layout so its very possible to have 100+layouts

  • The traditional programmers tell you global variables are bad. They do make the code a bit more difficult to handle in some respects but in terms of performance they will have no effect at all.

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