How many Global Variables is too much?

Discussion and feedback on Construct 2

Post » Fri Aug 01, 2014 3:56 pm

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?
B
46
S
13
G
7
Posts: 32
Reputation: 5,678

Post » Fri Aug 01, 2014 4:12 pm

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
B
79
S
22
G
4
Posts: 311
Reputation: 12,774

Post » Fri Aug 01, 2014 4:15 pm

Are you going to make 100 layouts?
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Fri Aug 01, 2014 4:27 pm

Just use an array and save the data locally using Webstorage.
B
33
S
12
G
7
Posts: 227
Reputation: 7,582

Post » Fri Aug 01, 2014 4:48 pm

Valerien wrote: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
B
46
S
13
G
7
Posts: 32
Reputation: 5,678

Post » Fri Aug 01, 2014 4:50 pm

A0Nasser wrote:Are you going to make 100 layouts?


Yes, each one being 1280, 720 in size. You can see the entire level on sceen.
B
46
S
13
G
7
Posts: 32
Reputation: 5,678

Post » Fri Aug 01, 2014 4:54 pm

KFC wrote: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.
B
46
S
13
G
7
Posts: 32
Reputation: 5,678

Post » Fri Aug 01, 2014 5:14 pm

There's no need for external files. Use Array (or dictionary) to store values and then use webstorage for saving and loading.
ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Fri Aug 01, 2014 5:17 pm

Thanks for the info everyone. This has saved me precious time and a headache.
B
46
S
13
G
7
Posts: 32
Reputation: 5,678

Post » Fri Aug 01, 2014 10:50 pm

@SEGamestudio
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.
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Yahoo [Bot] and 17 guests