I am currently in the process of creating a timer for a game but am getting a little confused about the best way to represent remaining time in the form of a bar. I have my timer up and running, and I was going to use this to scale an image to represent remaining time:
Time Passed / Total Time = Percentage Time Elapsed (x100 would be PTE but it’s easier without)
Image Width = (1 – PTE) * StartImageWidth
I can’t find any easy way of scaling an image in this format as the width param seems to be read only, and if I’m not mistaken the scaling functions are 4.x and later? So does anyone know the best way to do this?
Thanks,
Elliott
Try converting your bar image to a stretchableImage. I do something similar to this, but updating the time of day. Here’s my code:
Then you can adjust the width later using:
if you want to animate the change from the old frame to the new one, you can, but I think the main thing is the image has to be stretchable.