spritekit collisionBitMask互相传递

时间:2014-10-29 18:04:32

标签: objective-c sprite-kit

我有两个节点 - 兔子和平板。我怎么能让它通过彼此,以及我做错了什么?

static const uint32_t rabbitCategory = 0x1 << 1;
static const uint32_t slabCategory = 0x1 << 2;

rabbit.physicsBody.categoryBitMask = rabbitCategory;
rabbit.physicsBody.collisionBitMask = rabbitCategory;
slab.physicsBody.categoryBitMask = slabCategory;
slab.physicsBody.collisionBitMask = slabCategory;

2 个答案:

答案 0 :(得分:2)

我相信你想将collisionBitMask设置为物理体碰撞的类别:

rabbit.physicsBody.categoryBitMask = rabbitCategory;
rabbit.physicsBody.collisionBitMask = slabCategory;
slab.physicsBody.categoryBitMask = slabCategory;
slab.physicsBody.collisionBitMask = rabbitCategory;

答案 1 :(得分:0)

我找到了解决方案:

rabbit.physicsBody.categoryBitMask = rabbitCategory;
rabbit.physicsBody.collisionBitMask = borderCategory;

slab.physicsBody.categoryBitMask = slabCategory;
slab.physicsBody.collisionBitMask = slabCategory;