CGPointMake in Swift
Solution 1
Use CGPoint(x: Float, y: Float)
Solution 2
You call it a little differently, without the make.
CGPoint(x: 10, y: 20)
Solution 3
Xcode 6.3.1 shows 4 different Swift initializers for CGPoint. They are:
CGPoint()
CGPoint(x: CGFloat, y: CGFloat)
CGPoint(x: Double, y: Double)
CGPoint(x: Int, y: Int)
Solution 4
In the code it should looks like this (Xcode 6.1):
let point: CGPoint = CGPoint(x:10,y:10)
Rafał Sroka
sSSSs SSSSSSS SSSSSSS SSSSS .--' '--. / \ / | | \ / / \ : / \ \ ( ( ) : ( ) ) \ \ / \ / / _`\/ . \/`_____ /~~; ;~~~~~/| / '.__|__.' _/ /__________________/ | |
Updated on April 19, 2020Comments
-
Rafał Sroka about 4 years
How to use
CGPointMake
inSwift
? Is there an equivalent for it? I am getting an error:Use of unresolved identifier 'CGPointMake'
Basically, I am trying to assign a position to a Sprite Kit node and cannot figure out how to do it in Swift.
class PlayerSpaceship: Spaceship { func launchMissile() { var missile = Missile.playerMissile() // This line gives above mentioned error. missile.position = CGPointMake(0.0, 0.0) } }
-
Cœur over 5 years
let point = CGPoint(x: 10, y: 10)
should be enough in Swift.