How do I properly fade in and fade out a sprite?

0 favourites
  • 5 posts
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • When enemy sprites are created I want them to fade in. When they are killed I want them to fade out and be destroyed.

    I'm using the logic below, but seeing the following behavior:

    - when I press 'i', the sprite instantly appears but doesn't fade in - why not?

    - if I press 'o' within 2 seconds of pressing 'i', the sprite fades out and is destroyed - this is what I would expect

    - if I press 'o' more than 2 seconds after pressing 'i', the sprite instantly disappears and is destroyed - why is it not fading out?

    I'm obviously not understanding how to use fade properly, can someone clarify this for me, and/or let me know how to do what I'm trying to accomplish?


  • Cannot tell from the info but if you want it to fade in you can set it to Enabled=yes and give it the settings it needs then on creation it automatically fades in. If you have any other events that use opacity they may interfere with fade. Fade is really just adjusting opacity so you could always use this instead.

  • Not actually sure with the fade behavior, but I recommend using Tween instead as it gives you greater flexibility. Here is a screenshot of Tween.

    Apply Tween to object, set opacity to object as 100 in the layout, set Tween in actions to 100 opacity for fade in, set Tween in actions to 0 opacity and destroy for fade out. You can control the timing as well and easing as well. Hope that helps!

  • Here's all you need, as lionz mentioned fading in on creation can pretty much all be handled by the behavior.

    If you use the restart fade action instead of the start fade action it might behave more in line with expectations as well.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the example and the explanation! It works, and very easy. Gotta see what else tween can do for me...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)