I'm trying to figure out that a SKSpriteNode has completely iterated over another SKSpriteNode
. This the code I have come up with so far,
if (node.frame.maxY == player.frame.minY) {
player.physicsBody?.collisionBitMask = collisionTypes.vortex.rawValue
}
I know it's simple enough, but I'm lost here.
Set the contactTestBitMask properties of both objects. then detect when they collide in the didBegin func and then detect when they stop colliding in the didEnd func
player.physicsBody?.contactTestBitMask = collisionTypes.bullet.rawValue
bullet.physicsBody?.contactTestBitMask = collisionTypes.player.rawValue
func didBegin(_ contact: SKPhysicsContact) {
//detect your collision and do what you need to do
//maybe set a bool to true if you have multiple collision types
}
func didEnd(_ contact: SKPhysicsContact) {
//check that the above collison is the one that ended
//run appropriate code for end collision
}