Fade in/ Fade out tween on animation

spinnerbox

  • Posts: 166
I have dying animation on my main charachter, though it has only one frame. This animation or should I say frame should fade in and then fade out in 4 seconds all toghether.

The main character has also idle animation which should also fade out and fade in across 4 seconds.

How do I do that with tween only on this partucular animation? Is it possible or should I try other aproach?

gamegirlxl

  • Posts: 713
I'm going to say first that doing a tween is like placing a time bomb.  You'll need to have the second tween in a "do after 2 seconds wrapper", since you'll have two 2 second tweens.  If your actor is at 0% opacity at the start, fade it to 100% over 2 seconds, then have the tween fading it to 0% (which will be in the do after 2 seconds wrapper).

If you need any further help, I can explain further or change the code.  I'm good with tweens. ;D

spinnerbox

  • Posts: 166
Ok. I partially understand what do you say. But I don't know where to start.

Should I add some event on the main charachter on which to attach the tween?
What would be that event?

Sorry I am new to Stencyl :)

Note: Dying animation or should I say the fade in/out tween should be played only after the health of the Hero goes equal or below zero. After the fade in/out tween is finished the health is being reset to full 100 percent. I have the health of the Hero stored into a game attribute called srHealth.

gamegirlxl

  • Posts: 713
I would reset the health immediately, and use a blue Boolean ("reset") to determine if the four second period is active.  Some blocks:

When health <= 0
Set health = 100 (or whatever 100% health is)
Trigger "spawn" (a custom event)
set "reset" to true
(Tween here)

When spawn happens
Do after 4 seconds
    Set "reset" to false