我用来创建这样的动画。如何从sprite工作表中选择特定的帧/图像?-LibGdx
private Animation handAnimation;
handAnimation=new Animation(0.25f, playAtlas.createSprites(RegionNames.HAND_ANIMATION),Animation.PlayMode.LOOP);
绘图像这样:
handTexture = handAnimation.getKeyFrame(animationTime, true);
batch.draw(handTexture, Constants.WORLD_WIDTH - (2 * handTexture.getRegionWidth()),Constants.WORLD_HEIGHT/4);
这里这个动画有4帧。 阿特拉斯文件是这样的:
hand.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
hand
rotate: false
xy: 1, 1
size: 102, 152
orig: 102, 152
offset: 0, 0
index: 1
hand
rotate: false
xy: 105, 1
size: 102, 152
orig: 102, 152
offset: 0, 0
index: 2
hand
rotate: false
xy: 209, 1
size: 102, 152
orig: 102, 152
offset: 0, 0
index: 3
hand
rotate: false
xy: 313, 1
size: 102, 152
orig: 102, 152
offset: 0, 0
index: 4
现在我想要得到这个精灵表的特定帧(第3张)的一些其他use.How我可以得到第三帧只?
还有一件事我想知道,是否可以用这样的精灵表来改变动画的顺序?如果是的话我该怎么做呢?
看他的星图文件索引号更改动画的方式你想要的任何时间。 playAtlas.createSprite( “手”,2);返回第2个精灵不是第3个。 – arv
动画 handAnimation;这怎么可能?@Abhishek Aryan –
Niranjana
@Niranjana从gdx版本1.9.5开始'动画'类现在是通用的,有[pull request](https://github.com/libgdx/libgdx/pull/4448)for一样。我相信你正在使用一些旧版本。 – Aryan