Reputation: 104
I try next code but get following error: "Consecutive statements on a line must be separated by ';'". Where am I wrong?
let moveLeft = SKAction.customActionWithDuration(0.0, actionBlock: {node: SKNode!, elapsedTime: CGFloat) -> Void in
node.physicsBody?.velocity = CGVectorMake(0.5, 0.5)
})
Upvotes: 1
Views: 1149
Reputation:
The parameters in a closure are like a tuple, they need brackets on both sides. Also you should explicitly unwrap the node's physicsBody (or use if let
if it might be nil).
let moveLeft = SKAction.customActionWithDuration(0.0, actionBlock: { (node: SKNode!, elapsedTime: CGFloat) -> Void in
node.physicsBody!.velocity=CGVector(dx: 0.5, dy: 0.5)
})
Upvotes: 2