How do I save my instance variable ?

Get help using Construct 2

Post » Sun Sep 18, 2016 6:19 am

HI, i'm just new here
So, i want to ask, how do i save my instance variable and load it to another layout,
i mean, imagine on the first layout you have a character with a health as an instance variable, with value 400.
as you play the game the character health was decreased by defeating some enemy, and now the value is 370.
the problem is, how to store the value (370) of health (instance variable) on first layout to the second layout
thanks before.
B
8
Posts: 9
Reputation: 318

Post » Sun Sep 18, 2016 10:33 am

The most easy way is to use the behavior Persist, this is here for this usage, it will save variable etc on each layout.
Or use a global variable
Or use a Array, array didn't reset on changing layout
B
18
S
7
G
1
Posts: 56
Reputation: 3,000

Post » Sun Sep 18, 2016 10:05 pm

@dieblume86 ,can you make an example how to save instance and load it to another layout using arrays ? thx before
B
8
Posts: 9
Reputation: 318

Post » Sun Sep 18, 2016 10:07 pm

if it's player health then use a global variable, that way it is just consistent across the game. If it's any other health such as enemy HP then you're unlikely to need it between layouts.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Mon Sep 19, 2016 8:57 pm

Here is an example when u use an array but it is not the most easy way.
It can be useful for advance prog if you know how to use an array.

https://dl.dropboxusercontent.com/u/100433852/SaveInstanceVariable.capx
B
18
S
7
G
1
Posts: 56
Reputation: 3,000


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, tarek2 and 26 guests