I can't figure out how to do this easily.
I read a few other threads, and it seems fairly straight forward to get a sprite to fade out, lets just say set the alpha to 50% to be simple:
just on the tk2dsprite:
Color color = sprite.color;
color.a = newAlpha; // calculated elsewhere
sprite.color = color;
This actually works fine, the problem is, that during tk2dSpriteAnimation, every time the frame changes, the material is reset. Additionally the material is somewhere cached and every instance of the animation fades out at the same rate.
Even if I just run the fade out code on a single animation, every instance of that animation which is playing starts to fade out.
Is it possible to get a method to do a fadeout? Basically, I want to specific the start % and end % of the fadeout. i.e. start fading out 80% of the way through the animation and finish fading out 100% of the way through the animation.
I know that I can get my code working if I created a new material for every frame (and for every instance) of the animation and reset the material whenever SpriteChanged event fires. However, this is a LOT of materials when we are talking about the types of effects I want to fade out.
The other argument could be that the fade should be in the animation itself. This is the next step if its really not possible in the code. However, Currently, I have one really big animation, for example a giant explosion. What I would really love to be able to do is have small and large explosions all using the same sprite sequence. Then, what I can say is "play from this frame to that frame" with a fade starting at a certain percentage... if this worked, I could use a single actual animation (sprite sheet) , and create many many many different animations.
Anyway, I don't think it's currently possible in 2d toolkit. But please let me know if it is or any thoughts?
Thanks!