Thursday, January 31, 2013

Adding fade effect to live wallpaper

On the andengine forum I received a request to add a fade in and fade out effect to the falling rose petals. We will use the AlphaParticleModifier to accomplish this. The first two values of the modifier give the start and end values in seconds for how long the effect will take place. The second two values are the start and end of the alpha effect with a range of 0.0 to 1.0. The alpha effect refers to the transparency of the particle with 0.0 being invisible.
// add some fade in and fade out to the particles
    particleSystem.addParticleModifier(new AlphaParticleModifier<Sprite>
  (0.0f,10.f,0.0f, 1.0f));
    particleSystem.addParticleModifier(new AlphaParticleModifier<Sprite>
  (25.0f, 40.0f, 1.0f, 0.0f));
I also received a request on how to animate the sprites. I will make that the topic of the next blog. It will be posted before the end of the week. So check back shortly. Thanks for reading.

No comments:

Post a Comment