How do I count the on-screen objects ?

Get help using Construct 2

Post » Mon Oct 20, 2014 8:46 pm

How do I count the on-screen objects ?

I tried the following methods and they work, but when there isn't any on-screen object, it still counts 1.
Image
B
49
S
15
G
6
Posts: 531
Reputation: 7,189

Post » Mon Oct 20, 2014 8:53 pm

When there are no enemies on the screen then that event won't run so the text doesn't get updated. You can use that first event and add an 'else: set text to 0'.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,630

Post » Mon Oct 20, 2014 9:14 pm

Try Count instead of PickedCount

edit: in addition to ramones's suggestion. Still not sure how that first method produces 1 for you though.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Oct 20, 2014 9:42 pm

@ramones
Thanks, I was looking at "Is on screen" at a property, not like a condition. This method works:
Image
Is this good, or is there a better way ?

@codah
"Count" picks all the objects, regardless the conditions before (I tried it before opening this thread)... "PickedCount" counts only the objects that respect the conditions.

My first method doesn't work because the condition "is on-screen" becomes 0/false when there is no on-screen object. An expression like "object.CountOnScreen" would had been useful in this case.
B
49
S
15
G
6
Posts: 531
Reputation: 7,189

Post » Mon Oct 20, 2014 9:53 pm

Yea sorry, I shouldn't take part in life until my second coffee.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Oct 20, 2014 10:00 pm

This is what I was saying about adding else:
onscreen.png
You do not have the required permissions to view the files attached to this post.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,630

Post » Tue Oct 21, 2014 2:28 am

@ramones
Thank you very much :)
B
49
S
15
G
6
Posts: 531
Reputation: 7,189


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests