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

Get help using Construct 2

Post » Fri Jul 04, 2014 3:17 pm

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? :)
B
5
Posts: 31
Reputation: 361

Post » Fri Jul 04, 2014 3:48 pm

"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).
B
6
S
1
Posts: 73
Reputation: 571

Post » Fri Jul 04, 2014 4:02 pm

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 :)
B
5
Posts: 31
Reputation: 361

Post » Fri Jul 04, 2014 4:10 pm

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
B
6
S
1
Posts: 73
Reputation: 571

Post » Fri Jul 04, 2014 4:20 pm

@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
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
33
S
9
G
7
Posts: 450
Reputation: 6,778

Post » Fri Jul 04, 2014 6:35 pm

Many thanks for your help!
OddConfection, you are brilliant. It solved my problem!
Thank you :D
B
5
Posts: 31
Reputation: 361


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests