Search code examples
swiftxcodecgpoint

Cannot convert value of type int to specified value CGPoint


I have some code that is supposed to swipe a sprite in any direction taking in an initial value of a CGPoint.

I tried setting up a variable for this as

    var initialLocation:CGPoint = 0

I know this is not how you're supposed to do it but I forgot how it goes.


Solution

  • It's a point, so it has to have two coordinates (x, y):

    var initialLocation: CGPoint = .zero
    

    or

    var initialLocation: CGPoint = CGPoint(x: 0, y: 0)