Count instances with certain propery or variable

Get help using Construct 2

Post » Sat Feb 01, 2014 11:46 am

Hello!

Me again.

How do you count instances with a certain property or variable value?

For example on this screen there are 10 blocks with the setting collision enabled. Or there are 10 blocks with the variable value set to True. How do I let Construct count that and return me the value of 10?


B
58
S
18
G
13
Posts: 447
Reputation: 10,740

Post » Sat Feb 01, 2014 11:50 am

create a global variable "Count"

on trigger (left button clicked or something)
for each object
object variable value is true
trigger once
- system add 1 to Count
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Feb 01, 2014 12:30 pm

@LittleStain

Took me a few minutes to figure out how you meant with the event coding, but then I understood what you meant. I have now applied it, with some tweaks from my original goal, to make it simpler.

Thank you.
B
58
S
18
G
13
Posts: 447
Reputation: 10,740

Post » Sat Feb 01, 2014 12:48 pm

easier:

event:
object variable = xyz
action:
set var_number = object.pickedcount
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Sat Feb 01, 2014 1:10 pm

@mindfaQ

Thank you, that was better!
B
58
S
18
G
13
Posts: 447
Reputation: 10,740


Return to How do I....?

Who is online

Users browsing this forum: wertt22 and 9 guests