16
Support / Make tk2dSpriteAnimator clip play for variable number ofseconds programmatically
« on: January 25, 2014, 07:22:37 pm »
I have a cooldown timer sprite animator whose animation clip I want to play for a variable number of seconds. So for example one instance the animation clip will take 60 seconds to complete, or take 10 seconds to complete.
I know of the ClipFps property, and I've been fiddling around with it's value, but I can't seem to figure out what I should be setting it at based on the number of seconds I want the clip to take.
Here's a code sample, maybe there's a better way to do this?
I know of the ClipFps property, and I've been fiddling around with it's value, but I can't seem to figure out what I should be setting it at based on the number of seconds I want the clip to take.
Here's a code sample, maybe there's a better way to do this?
Code: [Select]
// Take 60 seconds to cooldown.
CooldownTime = 60f;
StartCoroutine(CooldownTimer());
private IEnumerator CooldownTimer() {
cooldownSprite.Play("cooldown");
cooldownSprite.ClipFps = CooldownTime;
CooldownFinished = false;
yield return new WaitForSeconds(CooldownTime);
cooldownSprite.Play("ready");
CooldownFinished = true;
}