【发布时间】:2015-01-20 08:44:43
【问题描述】:
无法应用冲动,在 xcode6.1 osx playground 中收到错误“找不到成员应用冲动”。
代码:
func spawnSand() {
let sand: SKSpriteNode = SKSpriteNode(imageNamed: "sand")
sand.position = CGPoint(x: random(min:0 , max: scene.size.width),
y: scene.size.height - sand.size.height)
sand.physicsBody = SKPhysicsBody(circleOfRadius: sand.size.width/2)
sand.physicsBody!.restitution = 0.9
sand.physicsBody!.density = 20.0
sand.name = "sand"
scene.addChild(sand)
}
func shake() {
scene.enumerateChildNodesWithName("sand") { node, _ in
node.physicsBody.applyImpulse(
CGVector(dx:0 , dy: random(min: 20 ,max:40))
)
}
}
【问题讨论】:
标签: ios macos xcode6.1 swift-playground