[英]How to make one-time animation?
I just wonder, how to make one time animation. 我只是想知道如何制作一次动画。 I have a lot of animations, but they, unfortunately, are repeating in the loop, and that's not what I wanted.
我有很多动画,但是不幸的是,它们在循环中不断重复,这不是我想要的。 Here's some code fragments:
以下是一些代码片段:
public void act(float delta) {
super.act(delta);
stateTime += Gdx.graphics.getDeltaTime();
TextureRegion currentFrame = activeAnimation.getKeyFrame(stateTime, true);
setDrawable(new TextureRegionDrawable(currentFrame));
}
RUNNING_ANIMATION_BY_SIDE = new Animation<TextureRegion>(0.333f,framesRunningBySide,Animation.PlayMode.LOOP);
SHOOTING_ANIMATION = new Animation<TextureRegion>(0.333f, framesShootingFront, Animation.PlayMode.NORMAL);
STEADY_ANIMATION = new Animation<TextureRegion>(0.230f, framesStandingFront, Animation.PlayMode.LOOP_RANDOM);
DYING_ANIMATION = new Animation<TextureRegion>(0.230f, framesDyingFront,Animation.PlayMode.NORMAL);
setActiveAnimation(STEADY_ANIMATION);
How to make my actor to play animation only one-time? 如何让我的演员一次只播放动画? As you see, I've set to DYING_ANIMATION a PlayMode.NORMAL .
正如你看到的,我已经设置为DYING_ANIMATION一个PlayMode.NORMAL。
You're using overloaded method getKeyFrame(float stateTime, boolean looping)
of Animation
class. 您正在使用
Animation
类的重载方法getKeyFrame(float stateTime, boolean looping)
。
If you pass looping true
as second parameter, your animation playmode will convert from PlayMode.NORMAL
to PlayMode.LOOP
如果将
true
作为第二个参数传递给循环,则动画PlayMode.NORMAL
PlayMode.LOOP
将从PlayMode.NORMAL转换为PlayMode.LOOP
so use getKeyFrame(float stateTime)
or pass false
as second parameter but for STEADY_ANIMATION
playmode will converted from PlayMode.LOOP_RANDOM
to PlayMode.LOOP
. 因此,请使用
getKeyFrame(float stateTime)
或将false
用作第二个参数,但对于STEADY_ANIMATION
PlayMode.LOOP_RANDOM
PlayMode.LOOP
STEADY_ANIMATION
PlayMode.LOOP_RANDOM转换为STEADY_ANIMATION
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.