I wanna in andEngine execute a sequence (sprite animation) when sprite collides with something. Tryed to define the sequenceEntityModifier in the IUpdateHandler but the sequence doesn't execute.
Any suggestion about how to achive this ? Where to put my animation code ?
sprite.registerUpdateHandler(new IUpdateHandler() {
@Override
public void onUpdate(float pSecondsElapsed) {
if(sprite.collidesWith(shape)) {
// this will not work
final SequenceEntityModifier enemyModifier = new SequenceEntityModifier(
...
)
// this too
sprite.setScale(0.5f);
}
}
@Override
public void reset() {
}
});
I guess you are not using Box2D, so register this IUpdateHandler to your sprite:
sprite.registerUpdateHandler(new IUpdateHandler() {
@Override
public void onUpdate(float pSecondsElapsed) {
if(sprite.collidesWith(shape)) {
//animation here
}
}
@Override
public void reset() {
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With