Libgdx动画控制器,针对淘汰动画进行优化

时间:2015-05-19 09:37:20

标签: animation 3d libgdx

我不想剔除用户看不到的所有动画。我尝试了一种粗糙的方式,如果动画对象不可见,我根本不调用AnimationController.update()。这不行,因为我不喜欢。因为当一个被淘汰的对象重新进入视图时,它将播放最后一个应用的动画(甚至是我们在剔除时应用的动画)这是我想的预期。动画仍然需要应用于剔除对象,因为它们可能会在动画中途进入视图。

我现在正在研究子类化AnimationController,并更改update()方法以考虑对象是否被剔除。如果是的话我不想只更新"时间"而不是做任何"沉重的"完全没有。

我的问题是我不确定什么是重要的部分,我需要更新/推进的最低限度。所以我希望对AnimationController类更有洞察力的人可以帮助我一点点?欢迎任何帮助,谢谢!

/** Update any animations currently being played.
 * @param delta The time elapsed since last update, change this to alter the overall speed (can be negative). */
public void update (float delta) {
    if (paused) return;
    if (previous != null && ((transitionCurrentTime += delta) >= transitionTargetTime)) {
        removeAnimation(previous.animation);
        justChangedAnimation = true;
        animationPool.free(previous);
        previous = null;
    }
    if (justChangedAnimation) {
        target.calculateTransforms();
        justChangedAnimation = false;
    }
    if (current == null || current.loopCount == 0 || current.animation == null) return;
    justChangedAnimation = false;
    updating = true;
    final float remain = current.update(delta);
    if (remain != 0f && queued != null) {
        inAction = false;
        animate(queued, queuedTransitionTime);
        queued = null;
        updating = false;
        update(remain);
        return;
    }
    if (previous != null)
        applyAnimations(previous.animation, previous.offset + previous.time, current.animation, current.offset + current.time,
            transitionCurrentTime / transitionTargetTime);
    else
        applyAnimation(current.animation, current.offset + current.time);
    updating = false;
}

我希望我可以做一些事情,比如只提前过渡当前时间,保持和当前时间被淘汰......?

0 个答案:

没有答案