Global Variable Question

Discussion and feedback on Construct 2

Post » Mon Mar 18, 2013 9:33 am

Hi,

my current project has a lot of global variables. It is being designed for desktop only.

Does the amount of global variables have any adverse effect?
Is there any advantage to using more local variables or arrays instead.

Also the status bar on C2 tells me the current memory use for this project is around 74mb.

Is that good or bad or does it make no difference on a desktop project?

Thanks
B
44
S
15
G
9
Posts: 1,096
Reputation: 11,013

Post » Mon Mar 18, 2013 10:54 am

My Memory use is at 360mb so iI think 74 are very good.

Global variables are just for the security not good, cause they could get changed from the user.
B
15
S
6
G
6
Posts: 512
Reputation: 5,550

Post » Mon Mar 18, 2013 11:21 am

[QUOTE=spongehammer] Hi,

my current project has a lot of global variables. It is being designed for desktop only.

Does the amount of global variables have any adverse effect?
Is there any advantage to using more local variables or arrays instead.

Also the status bar on C2 tells me the current memory use for this project is around 74mb.

Is that good or bad or does it make no difference on a desktop project?

Thanks[/QUOTE]

It doesn't matter memory wise which kind of variables you use. Pretty much only difference between global/local/instance variables is visibility; using lots of global variables where it is unnecessary makes things really hard to control.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Mon Mar 18, 2013 11:27 am

An array of 100,000 values doesn't even take 1 mehgabyte , I don't think 20 variables would take a lot
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Mon Mar 18, 2013 1:24 pm

Global variables don't affect the estimated memory use in the status bar; that's exclusively determined by the images in the project. Compared to images, a global variable occupies negligable memory.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544


Return to Construct 2 General

Who is online

Users browsing this forum: humanescape, Zebbi and 7 guests