ID:1909340
 
Resolved
Transitional frames created when interrupting one animation for another did not respect time=0 frames beginning the new animation.
BYOND Version:508
Operating System:N/A
Web Browser:N/A
Applies to:Dream Seeker
Status: Resolved (508.1295)

This issue has been resolved.
Problem description:


I've got a screen sized image that I'm using with animate to show red as the player is damaged. The red flashed to full then fades away using animate().

Specifically, I'm setting the alpha to 255, then using animate(src,alpha=0,time=2).

I'm not sure if this is a no brainier or not, but whenever I'm taking damage, the screen does flash appropriately, but it will not animate again until that first animate completes.

In some cases, when it's called very frequently, animate will stop working all together and nothing will happen until the mob the player controls moves into a new loc, say from (2,2,1) to (2,3,1), as if too many animate calls happened at that location and it doesn't want to do any more...

Is this a bug or am I unaware of certain limitations of animate()?
Bumping because I'm still stumped on this one.
Here's what's happening: When animate() interrupts an existing animation, it will try to transition from the last interpolated frame into the new animation.

So let's say you're animating from alpha=255 to alpha=0, and the first animation stops on alpha=100. Then you set alpha=255 manually, and do animate(src,alpha=0,time=...) again. When the client receives the second animation, it sees the first is still ongoing, so it creates a transition appearance where alpha=100 (its current interpolated value). The transition is used as the start of the new animation instead of its intended start, so it's animating from 100 to 0 over that time period.

There's actually a good solution for this:

animate(src, alpha=255, time=0)
animate(alpha=0, time=2)

Given that 200 ms isn't a lot of time, I'd suggest changing that time to a higher value and using a different form of easing so that most of the alpha goes away quickly, and then it fades out more gradually. (Circular + out would be a good choice I think.) IMO that'll look a lot nicer.
Ah, I see, so instead of setting the variable, calling an animate with 0 time will cancel the current animation it's seeing?

Sounds good to me, thanks very much!

Edit: Tested it out. Same issue unfortunately. Not sure if setting src or not is supposed to happen in the second animate call, but I currently have it as...

animate(src, alpha=100, time=0)
animate(src, alpha=0, time=dur) //dur is a variable I'm using to set the speed of the animation
It's not that it cancels the current animation; starting a new animation will always do that. The time=0 basically says you want to move from the transitional state of the old animation into your brand new state immediately.

Transitions exist to gracefully exit one animation and start another. This is a good thing because for example if you had a verb that caused you to fade out, you wouldn't want repeat calls to make you fully visible again just to fade out again. But if you do plan to forcibly reset a value, a 0-time frame is the perfect way to do it.
You called animate() twice in a row with src. The second animate() should not have an object, because you want that to be a second step in the animation--not a brand new first-step animation.
I went ahead and changed it to not have src in the second call, but it still responds the same. Even more-so, I tried setting the time for the animation to 10 to see for sure and it is still playing the full animation before starting another one.

Even stranger though, after a number of calls are made like this, the animations just stop entirely, even though the procedure is still being called.

I'll make a small project to test and see if this occurs on a fresh environment.
I went and tested things out, and it appears that any successive calls to animate aren't working, but they are causing any current running animation to just slow down.

Here's the test world I've made, including source files.

https://dl.dropboxusercontent.com/u/25108410/testanim.zip

Click the verb to watch it fade out, clicking it repeatedly just slows down the current fade animation.
Dang, you're right. You've hit on a bug for sure.
*throws arms up in victory* YASS.

Bizarro! I'm helping! Bizarro!
Lummox JR resolved issue with message:
Transitional frames created when interrupting one animation for another did not respect time=0 frames beginning the new animation.