I am using sprite and Animated sprite. I used Animated sprite for 16 frames. For left,right,up,down and last 4 frames blast animation.
//animSprite.setCurrentTileIndex(leftCount);
When animated Sprite collide with sprite .. I want to show last 4 frames for 5 sec. How to make using andengine. I tried with Thread.sleep but its not working.
//For update i am using
scene.registerUpdateHandler(new IUpdateHandler() {
@Override
public void reset() {
}
@Override
public void onUpdate(final float pSecondsElapsed) {
checkCollision();
}
I able get last 4 frames number in logcat. But screen not updated..
How to refresh the scene .
checkCollision()
{
if(sprite.collidesWith(animSprite))
try
{
for (int i = 0; i < 4; i++) {
animSprite.setCurrentTileIndex(animBlast);
Log.v("balst",""+animBlast);
animBlast++;
if (animBlast> 15) {
animBlast= 12;
}
Thread.sleep(10);
}
}
catch (Exception e) {
// e.printStackTrace();
}
}
For
AnimatedSpriteyou have ansprite.animate(long[] pFrameDurations, int pFirstTileIndex, int pLastTileIndex, int loopCount)method, that does aloopCountof loops of frame changes frompFirstTileIndextopLastTileIndexwith frame durations also defined. I feel this is what you’re looking for.