Counting sprites on screen

Get help using Construct 2

Post » Sun Feb 02, 2014 3:08 pm

How do I count how many sprites with frame animation greater than zero are on the screen?

Thanks
B
74
S
13
G
4
Posts: 1,005
Reputation: 8,053

Post » Sun Feb 02, 2014 3:19 pm

Loop through them and indivudally check, if found, add 1 to counter.

var: counter int() = 0

event: for each sprite

sub:
event: compare animation frame not equal 0
event: sprite is on screen
subs action: add 1 to counter



After the loop, the counter holds number of sprites which are on screen with their current animation frame other then 0
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Sun Feb 02, 2014 3:25 pm

easier:
put all sprites you wanna count into a family



family compare frame > 0
family is on-screen: set spritesonscreen = family.pickedcountmindfaQ2014-02-02 15:26:59
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 » Sun Feb 02, 2014 4:36 pm

@lennaert: Thanks.

@mindfaQ: Thank you. Works like a charm.
B
74
S
13
G
4
Posts: 1,005
Reputation: 8,053


Return to How do I....?

Who is online

Users browsing this forum: ST314 and 34 guests