Class AnimGroup


public class AnimGroup extends AnimBuilder
Allows one to specify a group of one or more animations that will be queued up to be started on an Animator at some later time. All animations added to the group will be started in parallel.

 AnimGroup group = new AnimGroup();
 group.tweenXY(...).then().tweenAlpha(...);
 group.play(sound).then().action(...);
 // the two animation chains (the tween chain and the play/action chain) will run in parallel
 // after this group is added to an Animator
 anim.add(group.toAnim());
 
One can combine multiple animation groups to achieve any desired construction of sequential and parallel animations.

 AnimGroup group2 = new AnimGroup();
 group2.tweenXY(...).then().tweenAlpha(...);
 group2.play(sound).then().action(...);
 AnimGroup group1 = new AnimGroup();
 group1.delay(1000).then().add(group2.toAnim());
 group1.delay(500).then().play(sound);
 // group 1's two animation chains will be queued up to run in parallel, and the first of its
 // chains will delay 1s and then trigger group 2's chains, which themselves run in parallel
 anim.add(group1.toAnim());
 
It is of course also possible to add a group with a single animation chain, which will contain no parallelism but can still be useful for situations where one wants to compose sequences of animations internally and then return that package of animations to be sequenced with other packages of animations by some outer mechanism:

 class Ship {
   Animation createExplosionAnim () {
     AnimGroup group = new AnimGroup();
     group.play(sound).then().flipbook(...);
     return group.toAnim();
   }
 }
 
  • Constructor Details

    • AnimGroup

      public AnimGroup()
  • Method Details

    • add

      public <T extends Animation> T add(T anim)
      Adds an animation to this group. This animation will be started in parallel with all other animations added to this group when the group is turned into an animation and started via Animator.add(T) or added to another chain of animations that was added to an animator.
      Specified by:
      add in class AnimBuilder
      Throws:
      IllegalStateException - if this method is called directly or implicitly (by any of the AnimBuilder fluent methods) after toAnim() has been called.
    • toAnim

      public Animation toAnim()
      Returns a single animation that will execute all of the animations in this group to completion (in parallel) and will report itself as complete when the final animation in the group is complete. After calling this method, this group becomes unusable. It is not valid to call add(T) (or any other method) after toAnim().