User42590
User42590

Reputation: 2531

Image Squences AndEngine

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

Upvotes: 1

Views: 2298

Answers (2)

Plastic Sturgeon
Plastic Sturgeon

Reputation: 12527

You can create a TiledTextureRegion from a folder. The example below loads all the images from the folder "person" because its a walk cycle of a 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);
}

The images will be added in alphabetical order.

Upvotes: 1

Shihab Uddin
Shihab Uddin

Reputation: 6931

As much I get your question, you can't play an animation with several individual images. You should use only one Tiled image to achieve animation for a single sprite. The above image is ok to play a run animation. Why you searched to combine individual sprite for animation ?

For above image animation you can use

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

In this animate method you have four parameters. First parameters is responsible for each tiled animate duration, Second Parameter (here :0) is the starting index of the tiled sprite, Third parameter, (here :4)is the last index of the Tiled. Fourth parameters are a boolean value to looping the animation.

NB: I ignore your second row Tiled on above image here. happy coding:)

Upvotes: 1

Related Questions