1

I'm following a SpriteKit tutorial video from Rob Percival, and this line of code does not compile. It seems the syntax is out of date for getting the "mid x" and "mid y" values. What are the replacements for CGRectGetMidX() and CGRectGetMidY()?

CGPoint(x: CGRectGetMidX(self.frame),y: CGRectGetMidY(self.frame))
jscs
  • 62,161
  • 12
  • 145
  • 186
Justin
  • 167
  • 2
  • 12
  • 1
    Possible duplicate of [Where is CGRectGetMidX/Y in Swift 3](http://stackoverflow.com/questions/40035825/where-is-cgrectgetmidx-y-in-swift-3) – Hamish Nov 01 '16 at 08:50

1 Answers1

7

The syntax for just about everything changed with Swift 3.

You want:

man.position = CGPoint(x: self.frame.midX, y: self.frame.midY)

See the documentation for CGRect for more details.

rmaddy
  • 298,130
  • 40
  • 468
  • 517