【发布时间】:2018-02-09 19:10:38
【问题描述】:
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 运行良好!
但是不知道该怎么做?
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 ");
}
}
}
我也有
let playerCategoryBitMask:UInt32 = 1
let borderCategoryBitMask:UInt32 = 4
【问题讨论】:
标签: swift xcode sprite-kit bitmask