R to Reset Not Reset Everything

For questions about using Classic.

Post » Wed Nov 16, 2011 4:26 pm

I have found that when resetting the game:

<code snippet>
+ MouseKeyboard: On key R pressed
-> System: Go to layout 1 with transition "None" lasting 0 MS

It does not always reset everything. Like when a boss ship comes:

<code snippet>
+ System: Is global variable 'Score' Greater or equal 5000
-> System: Set global variable 'Mode' to 1

+ System: Is global variable 'Mode' Equal to 1

+ System: Every 2000 milliseconds
-> BossMovePoint: Set position to Hero.X+random(20)-10, 100
-> Boss001: Set speed : 50 towards BossMovePoint

Or when this item gets updated in the top GUI:

<code snippet>
+ Hero: On collision between Hero and PurpleCross
-> System: Add 1 to global variable 'JesusScore'
-> PurpleCross: Destroy

+ System: Is global variable 'JesusScore' Equal to 1
-> JESUS: Set animation frame to 2

...and so on to frame 6.

Any thoughts about this?

Thank you.
B
5
S
1
G
1
Posts: 157
Reputation: 1,219

Post » Wed Nov 16, 2011 5:24 pm

Going to a layout isn't supposed to reset global variables.

If you want to reset global variables, you have to do it in some function that you'll call from that event. The event will take to the next (or same) layout, and the function will set the global variables values to the value you want them to have (in this case their default value).
By the way, it doesn't reset the values of private variables of global objects either. So you have to set them manually too.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Wed Nov 16, 2011 6:18 pm

So, call to an EVENT, say in "start of layout" opposed to starting the layer itself?
B
5
S
1
G
1
Posts: 157
Reputation: 1,219


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest