1

I am very new to ANDENGINE. I am trying to work on animated sprites now at that time I have sprite animated object like image1, image2 ,image3 . In these images a sequence of animation will be performed . Now in ANDENGINE for animation TiledTextureRegion is used which use only one image in which sprite animations are given like image below so is there any way to run a sprites animation using image sequences. I searched a lot on it, but it appears that there is very few information on that topic because andengine give ease but at that time I have to do that, and I am unable to think that how to start or use any method to achieve this.

enter image description here

4

2 回答 2

1

您可以从文件夹创建 TiledTextureRegion。下面的示例从文件夹“person”加载所有图像,因为它是一个人的步行周期。

BuildableBitmapTextureAtlas texture = new BuildableBitmapTextureAtlas(engine.getTextureManager(), 256, 64);                     
personTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAssetDirectory(texture, context.getAssets(), "person");
try {
        texture.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 4));
        texture.load();
} catch (TextureAtlasBuilderException e) {
        Debug.e(e);
}

图像将按字母顺序添加。

于 2013-04-24T20:02:22.673 回答
1

正如我得到你的问题一样,你不能用几个单独的图像播放动画。您应该只使用一个平铺图像来实现单个精灵的动画。上图可以播放跑步动画。为什么你要结合单个精灵来制作动画?

对于上面的图像动画,您可以使用

    yourSprite.animate(new long[] { 110, 110, 110, 110 ,110 }, 0, 4, true);

在这个动画方法中,您有四个参数。第一个参数负责每个平铺动画的持续时间,第二个参数(这里:0)是平铺精灵的起始索引,第三个参数,(这里:4)是平铺的最后一个索引。第四个参数是循环动画的布尔值。

注意:我在这里忽略了您在上图中平铺的第二行。快乐编码:)

于 2013-04-24T07:12:18.543 回答