How to make a limit function?
Weiyu
Member Posts: 216
Hello everyone!
I have a question about HP bar.
I want to make a HP bar which limit is 100.(width)
Actore will add 30 (width) when he eat the food.
I can make this function.
But I have no idea how to do HP bar's limit.
I always let HP bar exceed the limit.
Please help me・゚・(ノД`;)・゚・
Comments
Here is one way to make a health bar:
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Thank you for answer.
But he didn't teach me how to do HP bar limit.><"
Can't you just use a rule
If health bar => 100
Constrain width to 100
It will reach a 100 then no higher.
I've been out of GS for a while, but it should go something like this when you collect the food:
Change attribute self.width to min(100,self.width+30)
This should limit the hp bar width to 100 pixels.
Mental Donkey Games
Website - Facebook - Twitter
@mme5566123twww, I've attached an updated demo project that limits the health to a minimum of 0 and a maximum of 100.
The two rules that do this are in the plus and minus health buttons. They only allow the subtraction or addition of health as long as it's between 0 and 100.
Hope it helps.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page