I'm new to AndEngine. I want to simply play an animation on the center of the screen by using sprite sheet (I'm using TexturePacker for creating sprite sheet) can anyone help me with this requirement?! I didn't find any good complete tutorial for the same! Thanks in advance.
Asked
Active
Viewed 178 times
1 Answers
2
First load Sprite sheet as follows:
TexturePackLoader texturePackLoader = new TexturePackLoader(this.getAssets(), this.getTextureManager());
TexturePack gameTexPack = texturePackLoader.loadFromAsset("gfx/JumpingJack.xml", "gfx/");
gameTexPack.loadTexture();
TexturePackTextureRegionLibrary mTextureRegionLibrary = gameTexPack.getTexturePackTextureRegionLibrary();
You can play animation of frames as follows:
public static AnimatedSprite getAnimatedSprite(int textRegId, int framesCount){
int counter=0;
ITextureRegion[] iTextureRegions = new ITextureRegion[framesCount];
for(int i = 0; i < 4; i++){
ITextureRegion textureRegion = GameActivity.activity.mTextureRegionLibrary.get(textRegId+i).deepCopy();
iTextureRegions[counter] = textureRegion;
counter++;
}
ITiledTextureRegion tiledTextureRegion = new TiledTextureRegion(iTextureRegions[0].getTexture(), iTextureRegions);
AnimatedSprite animSprite = new AnimatedSprite(0, 0, tiledTextureRegion, GameActivity.activity.getVertexBufferObjectManager());
return animSprite;
}

Rama
- 1,156
- 1
- 7
- 13
-
2Check it the way i have done. – Rama May 06 '14 at 09:03
-
Is that GameActivity a class from AndEngine library? Can you please upload your full source code.? – Favas Kv May 07 '14 at 09:21
-
No, it is not a lib class.Remove that GameActivity code and use it – Rama May 08 '14 at 04:10