More scene2d Love!

In the last post i outlined what’s left for a 0.9 release. Today i implemented the inherited alpha behaviour needed for Fade Actions. This allows you to apply a FadeIn/FadeOut/FadeTo action on a Group which will automatically apply it to the children. What we do is basically just modify the alpha value of the Group’s color and pass that down to it’s children (multiplied with its own parent’s alpha if there is one). We needed to change a few bits here and there.

  • Actor.render() and Stage.render() are now called Actor.draw() and Stage.draw() for consistency with SpriteBatch, Sprite and SpriteCache.
  • The Actor.draw() method has an additional parameter now called parentAlpha. This is the combined alpha value of an Actor’s parent and its parents. If you have a custom Actor implementation all you need too do is to set multiply your Actor’s alpha with the parentAlpha value.
  • Sprite.draw() has an overloaded method which takes an alphaModulation value. This is a convenience method and will multiply the sprites alpha value with the value passed termporarily for rendering

Everything else stays the same. Here’s a little example that instantiates 100 images, adds them to a Stage and applies fade-in and fade-out actions on the Stage’s root group forever.

Easy, huh? You can find the full code here.

Thanks to Riven over at #lwjgl for the discussion of this little silly issue as well as Paul who mentioned this approach in the comment section of the last blog post.

3 thoughts on “More scene2d Love!

  1. Tank you, oh no, i mean thank you very match, oh no, i mean very much! (rssss). Seriously, thank you very much, you save my day!

Leave a Reply

Your email address will not be published.