How do I count sprites in level.

Get help using Construct 2

Post » Tue Sep 29, 2015 1:58 pm

Hello
How can I count the number of enemies that exist in the level?
B
42
S
10
G
2
Posts: 111
Reputation: 3,773

Post » Tue Sep 29, 2015 2:19 pm

Sprite.Count
ImageImageImage
B
71
S
21
G
221
Posts: 3,650
Reputation: 124,229

Post » Wed Sep 30, 2015 6:26 pm

first make a global variable called sprite count then go to the action "for each" under the system object which allows you to say "for each "sprite" add 1 to sprite count.
Image keep updated on my new game: Still Human
B
12
S
4
G
1
Posts: 155
Reputation: 1,483

Post » Wed Sep 30, 2015 6:38 pm

probably better to go with blackhornets sprite.count (ie variable=sprite.count)
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,812

Post » Wed Sep 30, 2015 7:16 pm

KnivetonStudios wrote:first make a global variable called sprite count then go to the action "for each" under the system object which allows you to say "for each "sprite" add 1 to sprite count.


This will add 1 to the variable for each enemy every tick..
After 1 second with 10 enemies at 60 fps the variable would be 600
resetting it to 0 every tick before repeting the for each event would solve that ofcourse,
but enemy.count will allways stay at the amount of instances of the enemy object present, so using that would be much easier..
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


Return to How do I....?

Who is online

Users browsing this forum: imothep85, KTML5 and 8 guests