TextureRegion pollAnimation(float delta) {
// update the animation
animationTime += delta;
// fetch the current frame
String textureName = state.name().toLowerCase() + "-" + mob.getDirection().name().toLowerCase();
Animation<TextureRegion> ani = animations.get(textureName);
if(animationTime > ani.getAnimationDuration()) animationTime = 0; // reset the animationTime to prevent any possibility of overflow
TextureRegion frame = ani.getKeyFrame(animationTime, true);
// reset the animation
prevState = state;
state = requestedAnimations.poll();
if(state == null) state = AnimationState.IDLE;
if(state != prevState)
animationTime = 0; // if we're going to render a new animation, we should start it from the beginning, I think. Though, I could see this not ending up being a good idea... NOTE: this is not just set to zero because it seems this causes a divide by zero error when fetching the keyframe.
requestedAnimations.clear();
return frame;
}
MobAnimationController.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:miniventure
作者:
评论列表
文章目录