How do I Reset global values except of one

Get help using Construct 2

Post » Thu May 11, 2017 9:50 am

Hello there!

Ive a question:

On layout start i have a sound which introduces the gameplay. If the player is gameOver he can restart the game. Because there are many variables and position changes - iam using restart layout and reset global variables.

If the layout restarts the introducing sound shouldnt appear again. So i would need to reset all variables, except of the "playSoundAgain" variable.

Any ideas?
B
8
S
2
Posts: 140
Reputation: 998

Post » Thu May 11, 2017 10:10 am

@Congrats2u

Use Local Storage for anything you want to persist, like the "playSoundAgain" variable, save it before you reset the variables and load it at the start of the layout before you do anything else.
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
32
S
9
G
7
Posts: 444
Reputation: 6,731

Post » Fri May 12, 2017 7:02 am

@OddConfection

Thank you i will try this out!
B
8
S
2
Posts: 140
Reputation: 998

Post » Fri May 12, 2017 10:40 am

@Congrats2u

Another way is to use a sub event with a local variable and this chain of actions:

Set localVar to globalVarA
Reset all global variables
Set globalVarA to localVar
B
16
S
7
G
3
Posts: 395
Reputation: 3,693


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests