how to count how many of a specific sprite are existing

Get help using Construct 2

Post » Fri May 01, 2015 1:54 pm

hi guys, can you tell me how to count how many of a specific sprite are existing and only create a new one when its 0 ? thanks
B
38
S
16
G
2
Posts: 463
Reputation: 4,922

Post » Fri May 01, 2015 2:13 pm

@mariogamer - Sprites have a built in value called Count that keeps track of how many there are.

So all you have to do is check if it's 0
e.g.
System->Compare two values->Sprite.Count = 0
Find all the Construct 2 games that were on Steam Greenlight here
B
37
S
10
G
7
Posts: 490
Reputation: 7,080

Post » Fri May 01, 2015 2:42 pm

I have a spawner object that should spawn one instance of a bullet...so how should I proceed ?
System->Compare two values->bullersprite.Count = 0 > spawnerobject spawn missile sprite ???? like that ?

thanks
B
38
S
16
G
2
Posts: 463
Reputation: 4,922

Post » Fri May 01, 2015 3:54 pm

or you could make a trigger..

Sprite isOnScreen (invert it)

this will execute whatever actions when there isn't a sprite on the screen. although this doesn't work if you have sprites off screen and you want to count them in your condition.
B
100
S
33
G
16
Posts: 1,204
Reputation: 16,875


Return to How do I....?

Who is online

Users browsing this forum: BDPNGUINS, Waltuo and 10 guests