Count object instances based upon instance variable value

Get help using Construct 2

Post » Mon Mar 23, 2015 1:47 pm

Sorry form my noob, I need to maintain a text box/variable that keeps active count of object instances that have an instance variable of 'X'.
For example (if this worked) as a text box expression "sprite.instanceVar=1.Count"

Thanks for any assistance.
B
4
S
1
Posts: 7
Reputation: 364

Post » Mon Mar 23, 2015 1:54 pm

pick


event
pick all object
pick object by evaluate where object.var = X
action
set text.txt object.PickedCount
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,607

Post » Mon Mar 23, 2015 5:44 pm

Exactly what I was looking for, TKS!
B
4
S
1
Posts: 7
Reputation: 364

Post » Sat Dec 09, 2017 4:14 pm

I don't understand it :/
B
1
Posts: 3
Reputation: 131

Post » Sun Dec 10, 2017 2:04 am

@Darxoon
Say you have Enemy sprite with instance variable Health.
And you want to count all enemies with full health and display this number in MyText.

Add event
Enemy -> Compare instance variable Health=100 -> MyText set text to ("Enemies with 100% health:" & Enemy.PickedCount)
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
127
Posts: 1,761
Reputation: 67,843


Return to How do I....?

Who is online

Users browsing this forum: mattshallow and 16 guests