[SOLVED] How do I select objects using this criteria?

Get help using Construct 2

Post » Fri Apr 11, 2014 6:03 am

Hi guys, I've been trying to do this selection for a while now but I can't quite get it to work.

I'll summarise the issue I'm having:
- 10 sprites in 'All Objects' family. (Can be a random amount but for now I'm using 10)
- Family has instance variables of "Dead" and "Running".

Let's say 5 of those objects have the 'Dead' flag set - I only want to trigger an action if ALL the remaining 5 objects have the 'Running' flag set.
It seems so simple, but I just keep bashing my head against a brick wall. I'm running into issues trying to code it so would value some expert advise on this please!

Thanks in advance!
Zacros
Last edited by Zacros on Fri Apr 11, 2014 8:53 am, edited 1 time in total.
B
7
S
1
G
1
Posts: 16
Reputation: 1,109

Post » Fri Apr 11, 2014 7:30 am

One way could be to do this. Each is a seperate event.

Global number numPicked=0

Every tick -> set numPicked to 0
Family: is dead -> add family.pickedcount to numPicked
Family: is running -> add family.pickedcount to numPicked
NumPicked=family.count -> trigger action


Or you may be able to do this with two conditions in one event.

System: pick family by comparison family.dead+family.running>0
System: compare family.count=family.pickedcount
->trigger action
B
94
S
33
G
117
Posts: 5,389
Reputation: 75,339

Post » Fri Apr 11, 2014 8:53 am

Mate, that's perfect!
I used the second option - hadn't really looked at solving the problem in that way, so thank you!

Cheers
Zacros
B
7
S
1
G
1
Posts: 16
Reputation: 1,109


Return to How do I....?

Who is online

Users browsing this forum: draiza and 6 guests