How do I pass family variables from a Layout to another

Get help using Construct 2

Post » Sat Apr 12, 2014 1:10 pm

Hi there,
I'd like to use in Layout B family variable generated in Layout A but it seems changing layout resets them.
Any idea on how to do that ?
Thanks for the answer
Laurent
B
38
S
16
G
5
Posts: 269
Reputation: 5,964

Post » Sat Apr 12, 2014 1:44 pm

Laurent wrote:Hi there,
I'd like to use in Layout B family variable generated in Layout A but it seems changing layout resets them.
Any idea on how to do that ?
Thanks for the answer
Laurent


I'm fairly certain you have to use global variables if you want to carry variables between layouts.

You could set a global variable that sets the family variable so that when the new layout starts it still applies it to the whole family.
B
8
S
1
Posts: 76
Reputation: 949

Post » Sat Apr 12, 2014 1:52 pm

@izicial
Thanks, that's what I thought.
How do you do that ? I have 10 members in my family and 2 family variables?
B
38
S
16
G
5
Posts: 269
Reputation: 5,964

Post » Sat Apr 12, 2014 4:45 pm

Laurent wrote:@izicial
Thanks, that's what I thought.
How do you do that ? I have 10 members in my family and 2 family variables?


This capx shows when you press space bar it adds to the global variable. This in turn changes the family variable to = the global variable.

So change any events that change your family variable to instead change the corresponding global variable then in the same event make family variable = global.

Then when you start a new layout simply have the global variable set the family variable.

EDIT: The complexity of this will be determined if you need a variable for all 10 of the family members or not, if they are all different and need to be carried over then you need to setup global variables for all of them.
You do not have the required permissions to view the files attached to this post.
B
8
S
1
Posts: 76
Reputation: 949

Post » Sat Apr 12, 2014 8:14 pm

Thanks @Izicial,
10 sprites are inside my Family and the Family has 2 variables (Life and Mana). So every sprite has it own Life and Mana that evolve throough the game. These are the 10 Life and 10 Mana I want to pass from one Layout to the next
B
38
S
16
G
5
Posts: 269
Reputation: 5,964

Post » Sat Apr 12, 2014 10:14 pm

Laurent wrote:Thanks @Izicial,
10 sprites are inside my Family and the Family has 2 variables (Life and Mana). So every sprite has it own Life and Mana that evolve throough the game. These are the 10 Life and 10 Mana I want to pass from one Layout to the next


Oh if they ALL have there own separate values you could just forget the family values and run it all straight off Global variables and take away some of the confusion.
B
8
S
1
Posts: 76
Reputation: 949


Return to How do I....?

Who is online

Users browsing this forum: kizlengames and 6 guests