I am developing a platform game using AndEngine. Character keeps running and collect coins. I am playing sound when character collides with some coin. It works fine when coins are in horizontal sequence and are at some distance relative to each other. But when character collides with bunch of coins, character jerks and game slow downs the body's velocity. Character's speed suddenly comes close to zero.
Character's sprite is connected to a physics body and I am settings its speed using body.setLinearVelocity()
method. Here is how I am detecting collision of sprite and coins and playing sound.
protected void checkCoinCollisions() {
for(int i = mCoins.size() - 1; i >= 0; i--) {
Coin coin = mCoins.get(i);
if(hero.collidesWith(coin)) {
mCoinsCollected++;
mScene.detachChild(coin);
coinSound.play();
mCoins.remove(coin);
}
}
}
Any idea how to remove this slowdown of character and jerk?