How do I make smooth moving hp bar?

Just started using Construct 2? Post your questions here

Post » Fri May 09, 2014 8:44 am

Hello! I created the hp bar to show the character hp value and set width to current hp/maxhp*100. It works good but character hp bar reduce its width step by step and what I actually need that it should change its width smoothly moving. How can I do this?
B
7
S
1
Posts: 73
Reputation: 603

Post » Sat May 10, 2014 7:16 am

There is extremly nice Tutorials about it :)
I tried it and this is good !

https://www.scirra.com/tutorials/182/ma ... cy-lifebar
B
15
S
4
Posts: 57
Reputation: 1,792

Post » Sat May 10, 2014 9:40 am

True. But there is no solution to my problem. I need hit point bar moving and in tutorial it only depends on value and it is not moving from right to left
B
7
S
1
Posts: 73
Reputation: 603

Post » Sat May 10, 2014 9:42 am

I am sorry but I don't get it so...
B
15
S
4
Posts: 57
Reputation: 1,792

Post » Sat May 10, 2014 9:58 am

In tutorial we have 100hp and when enemy attacks we then have 95 hp for example and hp bar set width to 95. What I need that it's width should be reducing 100,99,98,97,96,95
B
7
S
1
Posts: 73
Reputation: 603

Post » Sun May 11, 2014 12:32 am

Here you go.
test.capx

Untitled2.png
You do not have the required permissions to view the files attached to this post.
B
6
Posts: 16
Reputation: 282

Post » Sun May 11, 2014 6:56 am

you could also look at using lerp.

so if you had an instance variable called ivHealth

healthbar set width to lerp(self.width,self.ivHealth,0.01)
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Sun May 11, 2014 11:08 am

RamPackWobble wrote:you could also look at using lerp.

so if you had an instance variable called ivHealth

healthbar set width to lerp(self.width,self.ivHealth,0.01)


Awesome! Thank you very much!
B
7
S
1
Posts: 73
Reputation: 603

Post » Thu Feb 04, 2016 2:39 pm

RamPackWobble wrote:you could also look at using lerp.

so if you had an instance variable called ivHealth

healthbar set width to lerp(self.width,self.ivHealth,0.01)


Hey, I'm currently using event:
healthbar set width to "(HP/maxHP)*barMaxHP.Width"

With my healthbar being a sprite that places itself on another sprite which is the maxHP.
How do I combine this code with the Lerp thingy? I can't figure it out since I don't really understand perfectly what lerp does.
B
10
S
2
G
1
Posts: 51
Reputation: 858


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests