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
37
S
16
G
2
Posts: 447
Reputation: 4,865

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
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
33
S
9
G
7
Posts: 450
Reputation: 6,780

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
37
S
16
G
2
Posts: 447
Reputation: 4,865

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
97
S
32
G
16
Posts: 1,199
Reputation: 16,680


Return to How do I....?

Who is online

Users browsing this forum: evillair, vankizzle, Yahoo [Bot] and 8 guests