我已经查看并找到了单个碰撞的答案,但我正在寻找一种方法来检测不止一种类型的碰撞。我正在制作一个我想要 3 次碰撞的游戏。用户平面与敌方子弹相撞,用户的子弹与敌方飞机相撞(我已经在工作),以及敌方子弹和用户子弹相撞。我已经设置并纠正了所有 categoryBitMask 和 contactTestBitMask。这是我的委托方法。
 - (void) didBeginContact:(SKPhysicsContact *)contact {
SKPhysicsBody *firstBody, *secondBody;
if (contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask)
{
    firstBody = contact.bodyA;
    secondBody = contact.bodyB;
}
else
{
    firstBody = contact.bodyB;
    secondBody = contact.bodyA;
}
// if user plane hits enemy bullet
if ((firstBody.categoryBitMask == playerShipCategory) &&
    (secondBody.categoryBitMask == enemyBulletCategory)) {
    [self takeDamageByAmount:POINT_INCREMENTER];
    [_enemyBullet removeFromParent];
    SKAction *bounce = [SKAction sequence:@[
                                            [SKAction fadeAlphaTo:.5 duration:.2],
                                            [SKAction fadeAlphaTo:1.0 duration:.2],
                                            [SKAction fadeAlphaTo:.5 duration:.2],
                                            [SKAction fadeAlphaTo:1.0 duration:.2]
                                            ]];
    [_playerPlane runAction:bounce];
}
// if the user bullet hits the enemy bullet
else if ((firstBody.categoryBitMask == bulletCategory) &&
   (secondBody.categoryBitMask == enemyBulletCategory)) {
    [_enemyBullet removeFromParent];
    [_bullet removeFromParent];
}
// if bullet hits enemy ship - THIS ONE WORKS, but none of the others work for some reason
else if ((firstBody.categoryBitMask == bulletCategory) &&
    (secondBody.categoryBitMask == enemyShipCategory)) {
    [self gainPointsByAmoint:POINT_INCREMENTER];
    [self projectile:(SKSpriteNode *)firstBody.node didCollideWithMonster:(SKSpriteNode *)secondBody.node];
}
}