我有节点(沙子)向下坠落。
我有其他静态的节点(墙)。
当沙子碰撞时,如何让墙壁不移动?
let wall = SKSpriteNode(texture: chosen)
wall.position = location
wall.physicsBody = SKPhysicsBody(circleOfRadius: sprite.frame.width)
wall.physicsBody?.affectedByGravity = false
wall.physicsBody!.categoryBitMask = BLOCK
self.addChild(wall)
//////////
let sand = SKSpriteNode (imageNamed: img)
var randLoc = arc4random_uniform(26)
sand.position = CGPointMake(location.x - CGFloat(10) + CGFloat(randLoc), location.y)
self.addChild(sand)
//gravity
sand.physicsBody = SKPhysicsBody(circleOfRadius: sand.frame.width)
sand.physicsBody?.affectedByGravity = true
//contact
sand.physicsBody!.categoryBitMask = self.PARTICLE
sand.physicsBody?.collisionBitMask = self.BLOCK | self.PARTICLE
答案 0 :(得分:2)
如果你有wall.physicsBody?.dynamic = false
& sand.physicsBody?.dynamic = true
那么你应该能够在没有被沙子推动/移动墙壁的情况下检测到接触。 - Daniel Mihaila