如何排除多个物理主体collisionBitMask

时间:2017-02-05 13:55:47

标签: objective-c collision-detection physics skspritenode

我从其他SO'回答你可以通过在比特掩码中使用〜来排除相同类型的spritenode物理体的碰撞:

    self.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:self.size.width/2.0];
    self.minionLife = 1.0;
    self.minionSpeed = 60.0;
    self.minionPath = 0;
    self.physicsBody.categoryBitMask = cat_enemy1;

    // does not collide with itself
    self.physicsBody.collisionBitMask = ~cat_enemy1; // here

问题是如何为此collisionBitMask添加更多排除项?

我试过了:

self.physicsBody.collisionBitMask = ~cat_enemy1 | ~cat_playerShip; // here

但不行。

1 个答案:

答案 0 :(得分:1)

你必须或它然后否定它......:

… = ~cat_enemy1 & ~cat_playerShip;

...或者和它:

{{1}}