Hello I’m trying to create a Skill cooldown for my game.
Each skill have a timer.
I want to create a skill icon on the bottom of the screen and when I put an other object on it which will gradually disapear.
I tried to apply to scale it using the timer, but the problem is that it doesn’t do in % of the timer. Like if my timer is 6 second then the mask object I put will go bigger and bigger for 6 seconds.
It’s not really clear so I put an image to show.
So… convert it to % of the timer
The % of the timer, %t = elpased time / total time * 100
Then you have to scale, the scale is between 0-1 and the %t is between 0-100, scale = %t / 100
As you can see, you are multiplying and dividing by 100, you can resume it:
scale = elpased time / total time
If you already have scaled your object, I mean you need a global scale because the sprite size is too big, you need to multiply your scales:
scale = global scale * elapsed time / total time
Of course you have to modify the scale while elapsed time is <= total time, otherwise you’ll have a scale > 1 (or > global scale)
Oh thanks !! I’m really bad with numbers !
I think I’m almost there.
The only problem left is that right now, is that it’s little bit inverted from what I want.
It’s bit hard to explain so I made a drawing to explain.
And I’ll show you the code too.
You want to decrease the sprite size instead increase it?
scale = time elapsed / total time Increase from 0 to 1
scale = 1 - time elapsed / total time Decrease from 1 to 0
Ah thanks !
It’s so simple but I’m so bad with that kind of things !
It works well now !
Thank you again !