Life Bar Is Centered? Awww Heck No! Not This Time!
DepressedPanda
Member Posts: 215
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?
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
>-
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@