コード例 #1
0
  /** @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;
  }
コード例 #2
0
  /**
   * Increments each track entry {@link TrackEntry#getTrackTime()}, setting queued animations as
   * current if needed.
   */
  public void update(float delta) {
    delta *= timeScale;
    for (int i = 0, n = tracks.size; i < n; i++) {
      TrackEntry current = tracks.get(i);
      if (current == null) continue;

      current.animationLast = current.nextAnimationLast;
      current.trackLast = current.nextTrackLast;

      float currentDelta = delta * current.timeScale;

      if (current.delay > 0) {
        current.delay -= currentDelta;
        if (current.delay > 0) continue;
        currentDelta = -current.delay;
        current.delay = 0;
      }

      TrackEntry next = current.next;
      if (next != null) {
        // When the next entry's delay is passed, change to the next entry, preserving leftover
        // time.
        float nextTime = current.trackLast - next.delay;
        if (nextTime >= 0) {
          next.delay = 0;
          next.trackTime = nextTime + delta * next.timeScale;
          current.trackTime += currentDelta;
          setCurrent(i, next, true);
          while (next.mixingFrom != null) {
            next.mixTime += currentDelta;
            next = next.mixingFrom;
          }
          continue;
        }
      } else {
        // Clear the track when there is no next entry, the track end time is reached, and there is
        // no mixingFrom.
        if (current.trackLast >= current.trackEnd && current.mixingFrom == null) {
          tracks.set(i, null);
          queue.end(current);
          disposeNext(current);
          continue;
        }
      }
      updateMixingFrom(current, delta);

      current.trackTime += currentDelta;
    }

    queue.drain();
  }
コード例 #3
0
  private void updateMixingFrom(TrackEntry entry, float delta) {
    TrackEntry from = entry.mixingFrom;
    if (from == null) return;

    updateMixingFrom(from, delta);

    if (entry.mixTime >= entry.mixDuration && from.mixingFrom == null && entry.mixTime > 0) {
      entry.mixingFrom = null;
      queue.end(from);
      return;
    }

    from.animationLast = from.nextAnimationLast;
    from.trackLast = from.nextTrackLast;
    from.trackTime += delta * from.timeScale;
    entry.mixTime += delta * entry.timeScale;
  }