I am newbie to and-engine since working with it from fast two weeks. I am developing the ball game,My requirement as follows that when the ball touches to ground body for second time it should get destroy. I tried with update handler on ball sprite, its working fine when count reaches 2(I explicitly call remove logic).At the time it touches to ground body, I am destructing the ball body with the help of count in handler on Update(). Unfortunately for the first time also(count reaches 2 at first collision) body is getting destroyed. Above scenario is repeated often, worked with contact listener but no change.Any help would be appreciated.
@Override
public void onUpdate(float pSecondsElapsed) {
Shape path = new Rectangle(ballSprite.getX(),ballSprite.getY(), 10, 10);
if (ballCount <= 2) {
mScene.attachChild(path);
pathCoordinates.add(path);
dumpPathCoordinates.add(path);
}
if (ballSprite.collidesWith(ground)) {
ballCount++;
if (ballSprite.collidesWith(ground) && ballCount == 2) {
removePath();
removeBall(ballSprite);
addFace(10, 10);
}
}
}
Is it possible that the first touch lasts longer than one engine iteration? If so, you need to allow the ball removal only if this sequence occurs
touching->not touching->touching.So far the ball is removed even if the sequence is
touching->still touching.