How do I set my healthbar is Anchor in a platform.

0 favourites
  • 6 posts
From the Asset Store
HealthBar
$19.99 USD
Advanced, customizable, visual bars to present amounts of points such health, mana, stamina and more
  • Hello, I got a problem. I make a platform game, and I will have my healthbar be viewet in the top left edge of the game. The window scrolling with my player with help of the "ScrollTo" Behavior. I have set my Healthbar as an "Anchor" Behavior så it scroll with the player when the player moving.

    The problem is, when my player jump or fall, the healthbar is slower than the player, so the helthbar jumping up and down, but I will have it to stand still when my player jump or fall...

    Please, can anyone help me thanks?

  • "System > Every tick"

    "Set healthbar x > "Player.x - 200"

    "Set healthbar y > "Player.y - 200"

    This will set your healthbar in the top left of your player at all times. (If the scrollto behavior stops because of a wall, the healthbar will continue to move with it. For this you will need to make extra conditions to the every tick to only make it happen when nessecary).

  • Thanks, but I have tried it, but it don't work for me. If I do that you say, the healthbar following the player, and it will not be on the same place the whole time.

    I seraching for a function, like a menu, health, score panel on the top of my game, who not moving, but will be on the exacly same place the whole time, so it can be viewet.

    Hope anyone can help

  • You can also try:

    ViewportBottom(layer)

    ViewportLeft(layer)

    ViewportRight(layer)

    ViewportTop(layer)

    Return the viewport boundaries in layout co-ordinates of a given layer. Not all layers have the same viewport if they are parallaxed, scaled or rotated separately.

    From the manual:

    https://www.scirra.com/manual/126/system-expressions

  • DemantDigitalArt

    Put the HealthBar (and other UI elements) on a separate layer to the player with Parallax set to 0,0 - that way it will stay in position

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Many thanks for your help!

    OddConfection, you are brilliant. It solved my problem!

    Thank you

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