有人知道如何从特定索引(在我的情况下从当前索引)动画精灵吗?我尝试了一些但没有成功 -
if (!sprite.isAnimationRunning()) {
int index = sprite.getCurrentTileIndex();
sprite.animate(frameDurations, index, 7, true);
}
每次我都有异常,因为frameDurations不等于frameCount。我只想按下按钮时从currentIndex动画精灵。 :/
答案 0 :(得分:0)
sprite.animate(new long[]{}, "your current index", "your last index", loop );
Use this function to animate sprite from specific index to your last index. add how many number of
frames time to animate that from current index to last index . and loop is `boolean varible` that signifies animate once or `repeate`.
答案 1 :(得分:0)
这个精灵有8帧。我试图动画第7帧和第8帧。一旦完成,我将从第0帧到第6帧动画,其中100是持续时间
Player.sprite.animate(
new long[] { 100, 100 }, 7, 8,
false, new IAnimationListener() {
public void onAnimationStarted(
AnimatedSprite pAnimatedSprite,
int pInitialLoopCount) {
}
public void onAnimationLoopFinished(
AnimatedSprite pAnimatedSprite,
int pRemainingLoopCount,
int pInitialLoopCount) {
}
public void onAnimationFrameChanged(
AnimatedSprite pAnimatedSprite,
int pOldFrameIndex,
int pNewFrameIndex) {
}
public void onAnimationFinished(
AnimatedSprite pAnimatedSprite) {
Player.sprite.animate(
new long[] { 100,
100, 100,
100, 100,
100, 100 },
0, 6, true);
}
});