我正在按照教程使用applyImpulse从大炮中射出一个球,但它不能正常工作,只是在我触摸屏幕后才下降到底部?!
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
let ball:SKSpriteNode = SKScene(fileNamed: "Ball")!.childNodeWithName("ball")! as! SKSpriteNode
ball.removeFromParent()
self.addChild(ball)
ball.zPosition = 0
ball.position = cannon.position
let angleInRadians = Float(cannon.zRotation)
let speed = CGFloat(75.0)
let vx:CGFloat = CGFloat(cosf(angleInRadians)) * speed
let vy:CGFloat = CGFloat(sinf(angleInRadians)) * speed
ball.physicsBody?.applyImpulse(CGVectorMake(vx, vy))
}