How do I check object visibility in expression

Get help using Construct 2

Post » Fri Sep 01, 2017 4:49 am

Quick question - I noticed that objects in C2 have "Opacity" property, but there is no "Visibility" or "IsVisible" property.
Why? Or am I missing something?

I want to be able to check visibility in formulas, something like this:
Code: Select all
Score =  (Enemy.Health>0 & Enemy.IsVisible ? 5 : 1)


I know I can do the same by creating different conditions (Enemy Is Visible -> do this, Enemy Is Not Visible -> do that), but it makes the code much more cluttered - I'll end with 5 or 6 lines of code instead of 1.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
72
Posts: 1,085
Reputation: 39,233

Post » Fri Sep 01, 2017 5:57 am

I sometimes set it to either 0 or 100 opacity if it is something small and doesn't need to be destroyed
Image
B
30
S
8
G
1
Posts: 120
Reputation: 2,862

Post » Fri Sep 01, 2017 8:07 am

Yeah, changing opacity is a possible workaround, however today I needed to compare both opacity and visibility, hence this post..

I'm just wondering why such simple and obvious property doesn't exist.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
72
Posts: 1,085
Reputation: 39,233


Return to How do I....?

Who is online

Users browsing this forum: dop2000, hao102a2 and 27 guests