Battle and save state ?

Get help using Construct 2

Post » Tue Apr 05, 2016 3:17 am

Here my idea there two layout one for the dungeon crawling and the second one for the rpg turn based battle.

What Id like to do is to save the state of the prievous layout but when the battle is over id like to not only load the saved layout but also update the current variable such as Hp mana and item usage ?

And question will the on start of layout function counter act the load as in another on start event happens or can i do a control check of keeping that First time game loads from game start to never load again ?

Am i doing this part wrong ? or is layout the best or what ? :mrgreen:
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Tue Apr 05, 2016 5:31 am

Global variables are persistent and can be referred to in any layout.

The persist behavior can be used to save or keep track of objects' information while switching back and forth between layouts.

Arrays are also persistent through layout changes and are an excellent way to keep track of structured data.

On start of layout will occur any time that layout loads. If you want it to run once only, use a variable (for example a boolean called "FirstLoaded"), add a second condition to your start of layout event to check if "FirstLoaded" is false, and add an action in that event to set "FirstLoaded" to true. After running the first time, the variable will be true and that event will never run again even if the layout start triggers again.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Tue Apr 05, 2016 8:29 pm

oh nice i never thought of that boolean trick. To my understanding global variable cannot be a boolean ? will i have to slap it on to a global sprite ? and also what would be a good way to put this under ?
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Tue Apr 05, 2016 9:12 pm

Oh sorry you're right, you can't make a global variable boolean. In that case just make it a number and add 1 to it.
Code: Select all
Variable = 0

On Start Layout   |  Action - Do Something
If Variable = 0   |  Add 1 to Variable


Now that Variable is 1, that event will no longer run again even if you come back to your layout a second time. Unless you reset Variable to 0.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 8 guests