[SOLVED]Global Vars Wiped on New Layout?

Get help using Construct 2

Post » Thu Jun 14, 2012 1:42 am

Hey guys, My Global vars seem to get wiped when i load a new layout. I dont see a reset global vars function in my events. What causes this?KSLR2012-06-14 19:38:58
B
36
S
11
G
3
Posts: 279
Reputation: 8,371

Post » Thu Jun 14, 2012 1:47 am

if all global variables just use :
on start of layout : -> system : reset global vers to default.

or you can just put them your self like if you want just 1 global to reset do it like this :
on start of layout : -> system : set value to 0 or whatever...
B
52
S
15
G
6
Posts: 795
Reputation: 12,270

Post » Thu Jun 14, 2012 2:56 am

Ok I am having a really rough time loading new levels could someone take a look at my capx and give me a hand with this problem? It seems to me that when I load a new level all instances of my level are new. Maybe I am doing everything wrong?

Thanks in advance.

CAPX
B
36
S
11
G
3
Posts: 279
Reputation: 8,371

Post » Thu Jun 14, 2012 5:12 am

Your capx is pretty involved. Can you provide a brief description of what you are trying to achieve?

Is the problem you're having that the level goes black and all that is visible is a couple of text objects? Because that is what is happening for me.
B
30
S
12
G
12
Posts: 281
Reputation: 12,078

Post » Thu Jun 14, 2012 7:01 am

I increment the the level variable and it just resets back to 1 when I enter a new level.
B
36
S
11
G
3
Posts: 279
Reputation: 8,371

Post » Thu Jun 14, 2012 8:55 am

Well maybe my question was a little convoluted. I have a local variable on a sprite in my game that gets reset every time I load a new layout. Is that object not persistent?
B
36
S
11
G
3
Posts: 279
Reputation: 8,371

Post » Thu Jun 14, 2012 9:53 am

Local variables are only active within their scope, and do not transfer from layout to layout, you'll have to use global variables for that. (no increments)

Read about event variables here.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Thu Jun 14, 2012 2:02 pm

Local variables reset every tick by design.
Scirra Founder
B
382
S
222
G
84
Posts: 23,984
Reputation: 189,245

Post » Thu Jun 14, 2012 2:21 pm

You'd have to make the Shooter sprite global to keep it's instance variables between layouts.
B
55
S
28
G
19
Posts: 1,520
Reputation: 25,540

Post » Thu Jun 14, 2012 7:29 pm

ahhh. Thanks guys! testing now! beep beep beep beep

B
36
S
11
G
3
Posts: 279
Reputation: 8,371

Next

Return to How do I....?

Who is online

Users browsing this forum: emoaeden, purplemonkey, swad and 7 guests