Is it possible to make a variable number always have the exact same amount of digits in it including 0's and decimals.
For example, I want a variable that begins as 25.0 and counts down at a regular interval by 0.1. I want it to always have 2 numbers and 1 decimal place.
So it might be 22.2, or 05.3 etc.
Thanks in advance.
I haven't tried it. When you make a variable and do like that, does it say that it isn't possible?
I don't think thats possible.
But why do you need that ?
I'm taking the values of each digit and applying it to a sprites frame number.
At the moment if the value goes below 10.0 it loses the first digit and messes up my sprites.
Will this help?
Pad number out to a certain number of digits by adding zeroes in front of the number, then returning the result as a string. For example, zeropad(45, 5) returns the string "00045".
Develop games in your browser. Powerful, performant & highly capable.
That will help a lot. Thanks for that!