[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
32
S
9
G
3
Posts: 275
Reputation: 8,063

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
48
S
15
G
6
Posts: 795
Reputation: 12,035

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
32
S
9
G
3
Posts: 275
Reputation: 8,063

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
29
S
11
G
12
Posts: 281
Reputation: 11,888

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
32
S
9
G
3
Posts: 275
Reputation: 8,063

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
32
S
9
G
3
Posts: 275
Reputation: 8,063

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
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

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
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Thu Jun 14, 2012 7:29 pm

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

B
32
S
9
G
3
Posts: 275
Reputation: 8,063

Next

Return to How do I....?

Who is online

Users browsing this forum: Callan S, gamecorpstudio, Kagubro and 14 guests