【发布时间】:2016-11-05 08:38:20
【问题描述】:
在 SpriteKit 中,我们在 didBeginContact 方法中检测到 。 但这看起来有点愚蠢做这样的事情: func didBeginContact(contact: SKPhysicsContact) {
if let contactA = contact.bodyA.node?.name {
if let contactB = contact.bodyB.node?.name {
//now that we have safely unwrapped these nodes, we can operate on them
if contactA == "ball" {
collisionBetweenBall(contact.bodyA.node!, object: contact.bodyB.node!)
} else if contactB == "ball" {
collisionBetweenBall(contact.bodyB.node!, object: contact.bodyA.node!)
}
}
}
}
有什么方法可以确保 bodyA 始终是一个球?有没有与categorybitmask相关的规则?
【问题讨论】:
标签: objective-c swift sprite-kit game-physics