libgdx是新的,会添加到舞台演员执行动画,由几个帧组成。 这是我在网上找到的代码已经应用了我的运动图像:
public class AnimatedImage extends Image
{
private float stateTime = 0;
TextureRegion w1 = new TextureRegion(new Texture("wave/wave1 - Copy.png"));
TextureRegion w2 = new TextureRegion(new Texture("wave/wave2 - Copy.png"));
TextureRegion w3 = new TextureRegion(new Texture("wave/wave3 - Copy.png"));
TextureRegion w4 = new TextureRegion(new Texture("wave/wave4 - Copy.png")); //1088 308
Animation animation = new Animation(1f/4f, w1, w2, w3, w4);
public AnimatedImage(Animation animation) {
super(animation.getKeyFrame(0));
this.animation = animation;
}
@Override
public void act(float delta)
{
((TextureRegionDrawable)getDrawable()).setRegion(animation.getKeyFrame(stateTime+=delta, true));
super.act(delta);
}
}
现在,在Create()方法中,您可以声明该类并将其添加到舞台中吗? 型
Stage stage = new Stage();
AnimatedImage anim = new AnimatedImage() ;
stage.addActor (anim) ;
我会将动画视为演员,谢谢 这可能吗?