Hanuman Chu
Hanuman Chu

Reputation: 65

CGVectorMake is unavailable in Swift

I have a code snippet:

hero.physicsBody?.applyImpulse(CGVectorMake(0, 250))

I get this error for this line:

CGVectorMake is unavailable in Swift

Upvotes: 1

Views: 4301

Answers (2)

TheValyreanGroup
TheValyreanGroup

Reputation: 3599

In Swift 3 it has changed to CGVector()

hero.physicsBody?.applyImpulse(CGVector(dx: 0, dy: 250))

Upvotes: 16

Wes
Wes

Reputation: 1042

Change to:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    hero.physicsBody?.applyImpulse(CGVector(dx: 0, dy: 250))
}

Upvotes: 2

Related Questions