精灵工具包无法接收联系人消息节点

时间:2015-03-20 16:45:08

标签: ios sprite-kit

所以我让下面的代码接收联系人:

- (void) didBeginContact:(SKPhysicsContact *)contact{
SKPhysicsBody *firstBody,*secondBody;
if (contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask) {
    //player<enemy<abilities
    firstBody =contact.bodyA; // player
    secondBody = contact.bodyB; // enemy or abilities
} else {
    firstBody = contact.bodyB;//player
    secondBody = contact.bodyA;//enemy or projectile
}

if (firstBody.categoryBitMask == collisionCatergoryPlayer &&
    secondBody.categoryBitMask == collisionCatergoryEnemy) {
    NSLog(@"test");
    playerBall *ball = (playerBall *)firstBody.node;
    [ball removeFromParent];
    enemyBall *enemyBall1 = (enemyBall *)secondBody.node;
    [enemyBall1 removeFromParent];


} else if (firstBody.categoryBitMask == collisionCatergoryPlayer &&
           secondBody.categoryBitMask == collisionCatergoryAbilities){
    NSLog(@"upgrade");
    abilities *abilities1 = (abilities *)secondBody.node;
    //if theres abilities2 and 3,make a catergory bit mask for it and remove it from parent
    [abilities1 removeFromParent];
}

}

但是我无法从上面的代码收到nslog消息,请帮助!!!! 删除节点也没有做任何事情,我的位掩码是播放器

0 个答案:

没有答案