Family instance variables question

Get help using Construct 2

Post » Wed Aug 07, 2013 6:15 am

I'm trying to give different IDs to each instance of a family.

Suppose I have a family called Units that contains several different sprites. The family has a family instance variable called ID that starts at 0.

Each time I spawn a sprite, I set its ID to Units.ID + 1. Suppose I spawn 3 sprites - will the sprites have IDs of 1, 2, 3?

Just trying to figure out how to give different ID values to instances of a family.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,224

Post » Wed Aug 07, 2013 7:22 am

Hi Excal

If the family instance variable has a default value of 0.
And when you add a new sprite you set it to Units.ID(the default value) + 1
The new sprite's ID will be the default value + 1.

So in the mentioned case all your sprites IDs would be 1.

If you want different IDs for each you have to make a global variable which tracks the number of spawned sprites.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Wed Aug 07, 2013 7:28 am

Turns out I was being stupid and just needed to use UID ;)
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,224


Return to How do I....?

Who is online

Users browsing this forum: bbjGames, Iftikhar555, jpstudio, LaurenceBedford, OddConfection, Xeeko and 15 guests