Life Bar Is Centered? Awww Heck No! Not This Time!

Hey Chaps!

Simple and easy question that I'm having issues with because I suppose my brain is broken.

I have an Actor that's a plain ole red rectangle. Let's say I have 100 life assigned to a attribute to calculate the width of the bar.

100 Life = 100 Width. Easy!

NOT SO FAST COWBOY!

When it shrinks it, it resizes it from both sides meaning my life bar gets centered and shrinks. I'd like to to remain in the left position and shrink from the right side like most typical life bars.

How do I accomplish this feat of goodness in little ole gamesalad?

Comments

  • AxygamesAxygames Member, PRO Posts: 203


    :)>-
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I personally would suggest using an actor with the width set to 2 then use replicate to extend it to one direction with a spacing of 1and set the how many times value to the points attribute.
  • DepressedPandaDepressedPanda Member Posts: 215
    I personally would suggest using an actor with the width set to 2 then use replicate to extend it to one direction with a spacing of 1and set the how many times value to the points attribute.
    Smart. May do that. Thanks!

  • DepressedPandaDepressedPanda Member Posts: 215
    I personally would suggest using an actor with the width set to 2 then use replicate to extend it to one direction with a spacing of 1and set the how many times value to the points attribute.
    Only question is how you you delete the actors (the right amount) when the health is lost?
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    This is the same as the video above.

    Here you go >

    Constrain Attribute: self.size.Width To: max(0,min(game.health,100))

    The bar is constrained to the game.health attribute - but will be centered.

    If they have 5 'lives' then each hit means game.health starts at 100 and goes down by 20 - 0 is end game.

    To keep it left.

    Constrain Attribute: self.Position.X To: 50+(self.size.Width /2)

    Where 50 is the left edge - so that can be any number depending on where you want it.

    That way you can just alter the numbers and track anything from 2 hits to 1,000,000 coins.

    Where I use game.Health in the example above - in my game I don't do that, I call a table value and times it by a number to make my bar be a certain size but track different values.

    Cheers, M@

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I personally would suggest using an actor with the width set to 2 then use replicate to extend it to one direction with a spacing of 1and set the how many times value to the points attribute.
    Only question is how you you delete the actors (the right amount) when the health is lost?
    If you have set the how many times value to the health attribute then as it decreases it will reduce the replications as well
Sign In or Register to comment.