How to make a limit function?

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

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    Here is one way to make a health bar:

  • WeiyuWeiyu Member Posts: 216

    @jamie_c said:
    Here is one way to make a health bar:

    Thank you for answer.

    But he didn't teach me how to do HP bar limit.><"

  • ToqueToque Member Posts: 1,188

    Can't you just use a rule

    If health bar => 100

    Constrain width to 100

    It will reach a 100 then no higher.

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276
    edited January 2017

    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.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    @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.

Sign In or Register to comment.