Updating a parent instance variable

Get help using Construct 2

Post » Sat Mar 16, 2013 4:39 am

I have a sprite(Sprite A) with an instance variable that should be updated when another sprite(Sprite B) is destroyed. However my current method of updating by storing the UID of Sprite A in Sprite B it is not working properly when two Sprite B are destroyed at the same time.

Two questions:
Is there any other way of implementing such a parent-child relationship?

Is there any easy way of monitoring variables (debug mode) in Construct 2?
B
3
Posts: 5
Reputation: 360

Post » Sat Mar 16, 2013 7:25 am

For debugging I use chrome log plugin, it simplifies a lot of stuff :-)

It should not matter if two b instances are destroyed at same time, do you use on destroyed trigger? Posting a capx would allow us to help with this.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sat Mar 16, 2013 7:39 am

I've requested a parent child model implementation as did another. :(

Your best bet is to continue using a model to store the UID. Non effecient as it is. it is the only option.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Sat Mar 16, 2013 8:53 am



Here is the code I am using, the initial value for Health is 4 so in theory the final value after destroying all the EnemyTurret_01 should be 0. However, this does not occur when 2 are destroyed at the same time.Gyger2013-03-16 08:55:01
B
3
Posts: 5
Reputation: 360

Post » Sat Mar 16, 2013 9:14 am

[QUOTE=Gyger]
Here is the code I am using, the initial value for Health is 4 so in theory the final value after destroying all the EnemyTurret_01 should be 0. However, this does not occur when 2 are destroyed at the same time.[/QUOTE]

Seems you could do this: add 'for each' loop after health <= 0, OR add 'on destroyed EnemyTurret' trigger where you move the 'pick instance..' - part.

Also, it seems like your creation method could benefit from containers, or a for loop. You can use loopIndex to pin them to proper imagepoints: Spawn EnemyTurret_01 (image point "Turret_000"&loopIndex) :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sat Mar 16, 2013 10:10 am

That works, thanks.
B
3
Posts: 5
Reputation: 360


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, jul and 17 guests