0
例碰撞(在屏幕上的红色块),预先设定的节点不与用户触摸的创建的节点
var img = "BlockRed.png"
let sand = SKSpriteNode (imageNamed: img)
var randLoc = arc4random_uniform(26)
sand.position = CGPointMake(location.x - CGFloat(10) + CGFloat(randLoc), location.y)
sand.name = "redSand"
sand.zPosition = 0
self.addChild(sand)
//gravity
sand.physicsBody?.affectedByGravity = true
//contact
sand.physicsBody!.categoryBitMask = PARTICLE
sand.physicsBody?.collisionBitMask = BLOCK | PARTICLE
sand.physicsBody?.contactTestBitMask = BLOCK | PARTICLE
sand.physicsBody = SKPhysicsBody(circleOfRadius: sand.frame.width - 3)
但是,当它们接触时,颗粒刚好落在壁上。为什么会发生这种情况,我该如何解决?
注:
// Constants
let NOTHING: UInt32 = 0x1 << 0
let PARTICLE: UInt32 = 0x1 << 1
let BLOCK: UInt32 = 0x1 << 2
这没有奏效。还有其他建议吗? –
你能告诉我你当前的代码吗? – rakeshbs
我想通了,我发布了一个答案。谢谢你的帮助! –