Esempio n. 1
0
 /**
  * Sets the entity for this player instance. The animation will be switched to the first one of
  * the new entity.
  *
  * @param entity the new entity
  * @throws SpriterException if the entity is <code>null</code>
  */
 public void setEntity(Entity entity) {
   if (entity == null) throw new SpriterException("entity can not be null!");
   this.entity = entity;
   int maxAnims = entity.getAnimationWithMostTimelines().timelines();
   tweenedKeys = new Timeline.Key[maxAnims];
   unmappedTweenedKeys = new Timeline.Key[maxAnims];
   for (int i = 0; i < maxAnims; i++) {
     Timeline.Key key = new Timeline.Key(i);
     Timeline.Key keyU = new Timeline.Key(i);
     key.setObject(new Timeline.Key.Object(new Point(0, 0)));
     keyU.setObject(new Timeline.Key.Object(new Point(0, 0)));
     tweenedKeys[i] = key;
     unmappedTweenedKeys[i] = keyU;
     this.objToTimeline.put(keyU.object(), keyU);
   }
   this.tempTweenedKeys = tweenedKeys;
   this.tempUnmappedTweenedKeys = unmappedTweenedKeys;
   this.setAnimation(entity.getAnimation(0));
 }
Esempio n. 2
0
 /**
  * Sets the animation of this player to the one with the given index.
  *
  * @param index the index of the animation
  * @throws IndexOutOfBoundsException if the index is out of range
  */
 public void setAnimation(int index) {
   this.setAnimation(entity.getAnimation(index));
 }
Esempio n. 3
0
 /**
  * Sets the animation of this player to the one with the given name.
  *
  * @param name the name of the animation
  * @throws SpriterException if no animation exists with the given name
  */
 public void setAnimation(String name) {
   this.setAnimation(entity.getAnimation(name));
 }