我只需要知道用Animation
类和libgdx
改变框架位置的最佳方法:
我用许多TextureRegions
制作一个Animation
对象,我找到了这个解决方案来更新渲染方法中帧的位置:
batch.begin();
if (currentFrame.equals(tex1))
batch.draw(currentFrame, w, h,120,160);
else if (currentFrame.equals(tex2))
batch.draw(currentFrame, w+5, h+10,120,160);
batch.end();
这将在不同的位置按顺序绘制每一帧动画;这是一个好的解决方案,还是存在更好的解决方案?谢谢。
初始化动画对象后,只需使用getKeyFrame方法获取当前帧并使用batch:
绘制它TextureRegion currentFrame = animation.getKeyFrame(Gdx.graphics.getDeltaTime(), true);
batch.draw(currentFrame, 0, 0);