How do I count objects?

Get help using Construct 2

Post » Tue Apr 08, 2014 3:54 pm

Hello!
I need to count objects that are inside an area. For example: 2 objects of type A, 3 objects of type B and so on...

Do I use collision? Overlapping? Something like PickedCount (this one I didn't really understand)?

Any sample that you can show me?

Thank you!
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Tue Apr 08, 2014 7:23 pm

Yeah, you can use a For Each loop to check if an object is within an area by checking X and Y coordinates or overlapping, and add +1 to variable. If you have similar objects in a Family, that would allow fewer loops.
B
33
S
7
G
8
Posts: 312
Reputation: 8,528

Post » Tue Apr 08, 2014 7:45 pm

PickedCount is how many of the object is picked. So you check to see if it's overlapping the game area, which picks all those that are, then check the PickedCount to see how many are there.
B
36
S
11
G
10
Posts: 13
Reputation: 8,712

Post » Fri Apr 11, 2014 1:06 pm

Well done Manley! Listen.. is there anyway to use some kind of Tag to group some objects?
Thanks to you too Judy! Great to know that I can count how many objects one is overlapping!
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Fri Apr 11, 2014 2:24 pm

You can add an instance variable to the objects..called tag for example..and check if that variable is the one you're looking for
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643


Return to How do I....?

Who is online

Users browsing this forum: max2612 and 24 guests