func didBegin(_ contact: SKPhysicsContact) {
var firstBody: SKPhysicsBody
var secondBody: SKPhysicsBody
if(contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask)
{
firstBody = contact.bodyA
secondBody = contact.bodyB
}
else
{
firstBody = contact.bodyB
secondBody = contact.bodyA
}
if (firstBody.categoryBitMask & Constants().playerCategoryBitMask != 0)
{
if(secondBody.categoryBitMask & Constants().borderCategoryBitMask == 4)
{ touchingWall = true
print("Touching the wall ");
}
}
}
didBegin is working great!
However didEnd not sure how to do it?
func didEnd(_ contact: SKPhysicsContact) {
var firstBody: SKPhysicsBody
var secondBody: SKPhysicsBody
if(contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask)
{
firstBody = contact.bodyA
secondBody = contact.bodyB
}
else
{
firstBody = contact.bodyB
secondBody = contact.bodyA
}
if (firstBody.categoryBitMask & Constants().borderCategoryBitMask != 0 )
{
if(secondBody.categoryBitMask & Constants().playerCategoryBitMask != 0 )
{
touchingWall = false
print("Not Touching the wall ");
}
}
}
I also have
let playerCategoryBitMask:UInt32 = 1
let borderCategoryBitMask:UInt32 = 4