/** @param last May be null. */
  private TrackEntry trackEntry(
      int trackIndex, Animation animation, boolean loop, TrackEntry last) {
    TrackEntry entry = trackEntryPool.obtain();
    entry.trackIndex = trackIndex;
    entry.animation = animation;
    entry.loop = loop;

    entry.eventThreshold = 0;
    entry.attachmentThreshold = 0;
    entry.drawOrderThreshold = 0;

    entry.animationStart = 0;
    entry.animationEnd = animation.getDuration();
    entry.animationLast = -1;
    entry.nextAnimationLast = -1;

    entry.delay = 0;
    entry.trackTime = 0;
    entry.trackLast = -1;
    entry.nextTrackLast = -1;
    entry.trackEnd = Float.MAX_VALUE;
    entry.timeScale = 1;

    entry.alpha = 1;
    entry.mixAlpha = 1;
    entry.mixTime = 0;
    entry.mixDuration = last == null ? 0 : data.getMix(last.animation, animation);
    return entry;
  }
Esempio n. 2
0
  /** Set the current animation. Any queued animations are cleared. */
  public TrackEntry setAnimation(int trackIndex, Animation animation, boolean loop) {
    TrackEntry current = expandToIndex(trackIndex);
    if (current != null) freeAll(current.next);

    TrackEntry entry = Pools.obtain(TrackEntry.class);
    entry.animation = animation;
    entry.loop = loop;
    entry.endTime = animation.getDuration();
    setCurrent(trackIndex, entry);
    return entry;
  }
Esempio n. 3
0
  /**
   * Adds an animation to be played delay seconds after the current or last queued animation.
   *
   * @param delay May be <= 0 to use duration of previous animation minus any mix duration plus the
   *     negative delay.
   */
  public TrackEntry addAnimation(int trackIndex, Animation animation, boolean loop, float delay) {
    TrackEntry entry = Pools.obtain(TrackEntry.class);
    entry.animation = animation;
    entry.loop = loop;
    entry.endTime = animation.getDuration();

    TrackEntry last = expandToIndex(trackIndex);
    if (last != null) {
      while (last.next != null) last = last.next;
      last.next = entry;
    } else tracks.set(trackIndex, entry);

    if (delay <= 0) {
      if (last != null) delay += last.endTime - data.getMix(last.animation, animation);
      else delay = 0;
    }
    entry.delay = delay;

    return entry;
  }