So I am using the didBeginContact method to detect the collision between the physics bodies of a bullet and other objects in my scene using the block of code below:
-(void)didBeginContact:(SKPhysicsContact *)contact
{
uint32_t collision = (contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask);
if (collision == (WWPhysicsCategoryOther | WWPhysicsCategoryBullet)) {
[_bullet removeFromParent]
}
}
When one bullet is on the screen, the bullet is removed. However, like many shooting games, the player is allowed to fire bullets repetitively. I find that when more than one bullet is on screen, not all of them are removed after contact. How can I ensure that every bullet is immediately removed right after a collision?