Stillfinder
Stillfinder

Reputation: 104

SKAction.customActionWithDuration Consecutive statements on a line must be separated by ';'

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

Answers (1)

user4233369
user4233369

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

Related Questions