Say i have a sprite thats however many pixels in width and i want it to reflect how much health an object has.
It has a private value, 100 being full health and 0 being dead, whats the maths to make the sprite width shrink proportionaly to the value?
um, if your image point is at the most left or right of the sprite you can just do set width to ('health'), and itll work fine
or if you want it to be a give length you can do (('health')/100)*(put whatever the maximum of your bar length is here)
Just a note, you may wish to use a tiled background instead of a Sprite for a healthbar, if you want anything other than a solid colour.
Is that so the image doesnt get distorted?
Not sure if i can use the tiled background object because it doesnt allow private values, which i need.
Develop games in your browser. Powerful, performant & highly capable.
I've added them for the next build, but yes, that's why you'd use it .