Exemple #1
0
 /**
  * Sets the animation of this player.
  *
  * @param animation the new animation
  * @throws SpriterException if the animation is <code>null</code> or the current animation is not
  *     a member of the current set entity
  */
 public void setAnimation(Animation animation) {
   Animation prevAnim = this.animation;
   if (animation == this.animation) return;
   if (animation == null) throw new SpriterException("animation can not be null!");
   if (!this.entity.containsAnimation(animation) && animation.id != -1)
     throw new SpriterException("animation has to be in the same entity as the current set one!");
   if (animation != this.animation) time = 0;
   this.animation = animation;
   int tempTime = this.time;
   this.time = 0;
   this.update();
   this.time = tempTime;
   for (PlayerListener listener : listeners) listener.animationChanged(prevAnim, animation);
 }