gpt4 book ai didi

ios - *碰撞*通过位掩码

转载 作者:行者123 更新时间:2023-11-28 08:12:10 27 4
gpt4 key购买 nike

我试图不接触穴居人和其他带有碰撞位掩码的图像,但我的穴居人击中了一切。

func addCaveManBitMasks(){

caveManNode.physicsBody?.categoryBitMask = PhysicsCategory.caveman
caveManNode.physicsBody?.contactTestBitMask = PhysicsCategory.tri | PhysicsCategory.trex | PhysicsCategory.newblock | PhysicsCategory.fireBall | PhysicsCategory.waterblock | PhysicsCategory.secondwaterblock | PhysicsCategory.star
caveManNode.physicsBody?.collisionBitMask = PhysicsCategory.newblock
}
func addTriBitMasks(){

triImage.physicsBody?.categoryBitMask = PhysicsCategory.tri
triImage.physicsBody?.contactTestBitMask = PhysicsCategory.caveman
triImage.physicsBody?.collisionBitMask = 0
}
func addRexBitMasks(){
tRexImage.physicsBody?.categoryBitMask = PhysicsCategory.trex
tRexImage.physicsBody?.contactTestBitMask = PhysicsCategory.caveman
tRexImage.physicsBody?.collisionBitMask = 0
}
func addNewBlockManBitMasks(){
newBlockImageNode.physicsBody?.categoryBitMask = PhysicsCategory.newblock
newBlockImageNode.physicsBody?.contactTestBitMask = PhysicsCategory.caveman | PhysicsCategory.steg
newBlockImageNode.physicsBody?.collisionBitMask = PhysicsCategory.caveman
}
func addFireBallBitMasks(){
fireBall.physicsBody?.categoryBitMask = PhysicsCategory.fireBall
fireBall.physicsBody?.contactTestBitMask = PhysicsCategory.caveman
fireBall.physicsBody?.collisionBitMask = 0
}
func addStarBitMasks(){
onScreenStar.physicsBody?.categoryBitMask = PhysicsCategory.star
onScreenStar.physicsBody?.contactTestBitMask = PhysicsCategory.caveman
onScreenStar.physicsBody?.collisionBitMask = 0
}


struct PhysicsCategory {

static let caveman: UInt32 = 0x1 << 0
static let tri: UInt32 = 0x1 << 1
static let trex: UInt32 = 0x1 << 2
static let fireBall: UInt32 = 0x1 << 3
static let steg: UInt32 = 0x1 << 4
static let ptero: UInt32 = 0x1 << 5
static let waterblock: UInt32 = 0x1 << 6
static let secondwaterblock: UInt32 = 0x1 << 7
static let newblock: UInt32 = 0x1 << 8
static let star: UInt32 = 0x1 << 9
static let food: UInt32 = 0x1 << 10


}

tri、rex、fireball 和 newblock 彼此不接触,这是完美的,但我也需要穴居人做同样的事情。穴居人应该只碰撞 与它所做的新方 block 。我很困惑,非常感谢您的解释

最佳答案

这是因为您将所有其他对象 collisionBitMask 设置为与穴居人相同。将那些其他对象的碰撞位掩码更改为您尚未在另一个节点上使用的位掩码,因为它的类别,你会很好。

关于ios - *碰撞*通过位掩码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43418476/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com