在sprite kit中检测碰撞的理想方法?

时间:2014-04-22 10:09:02

标签: objective-c sprite-kit

-(void)handleContact:(SKPhysicsContact*)contact{

    NSArray *nodeNames = @[contact.bodyA.node.name, contact.bodyB.node.name];

    if ([nodeName containsObject:player] && [nodeName containsObject:window] {  //player and windows are defined strings which are set in SKSpriteNode names

        Do something to window

    } else if ([nodeName containsObject:player] && [nodeName containsObject:door])

        Do something to door
    } //Continue another 10 times with different defined strings except player

}

这种代码是否适合碰撞检测,还是有更好的方法可以解决这个问题?

0 个答案:

没有答案