Distance Opacity [SOLVED]

Get help using Construct 2

Post » Tue Jan 22, 2013 8:40 pm

I currently have this as a way to change the opacity of my death warning thingy. However I am nearing my 100 event limit and I'm trying to get rid of all these events because I know there is a simpler way.

I changed all of these to
-Every Tick
-> Set HudDeath Opacity to distance(Player.X, 0, 0, 0)

This is ALMOST perfect except that its reversed. So when you are near the left side of screen it is invisible, and when you are farther towards the right side it gets visible. I need it opposite of that. Is there any way to do this in 1-3 events?

SOLUTION:

- Every Tick
-> Set HudDeath.opacity to int(100 - (Player.X / 2))

Why didn't I think of that.EncryptedCow2013-01-22 22:07:30
B
40
S
12
G
7
Posts: 603
Reputation: 7,646

Post » Tue Jan 22, 2013 9:11 pm

Every Tick
Set HudDeath Opacity to ((Player.X/LayoutWidth*100)-100*-1)

So if the screen is 1200 units wide and the player is at X=720 then it should be 40% opacity

or 0% opacity when the player is all the way over on the right side of the layout and 100% opacity on the left side of the screenjustifun2013-01-22 21:19:59
B
50
S
21
G
8
Posts: 844
Reputation: 10,299

Post » Tue Jan 22, 2013 9:43 pm

I'm looking for something other than it being based on the overall x value. If the players X value is anywhere above 200 it should be 0, THEN the opacity needs to vary between 0 when Player.X = 201, and 100 when Player.X = 0. Does this make sense?

EDIT: This is it when using a bunch of events and is pretty much exaclty how I need it. I would use this but am getting close to my event limit and I know theres a way to do this in fewer eventsEncryptedCow2013-01-22 21:48:04
B
40
S
12
G
7
Posts: 603
Reputation: 7,646

Post » Tue Jan 22, 2013 10:23 pm

Ah ok in that case....

system compare 2 values
player.x <=200
--->every tick->set opacity = 100 - (Player.x/2)

Or to make it a bit more flexible

set Opacity to (1 - (player.x / xmax)) * 100

xmax will be a variable set to whatever the maximum distance from the left side of the screen you want the opacity to start going up (eg: 200 in your example) if you need to change it easily elsewhere in your game instead of hard coding that number

justifun2013-01-22 22:39:25
B
50
S
21
G
8
Posts: 844
Reputation: 10,299


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests