Distance Opacity [SOLVED]

0 favourites
  • 4 posts
  • 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?


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

    Why didn't I think of that.

  • 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 screen

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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 events

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)