2

I have an ellipse that I want to draw in the center of the scene

 let center = (view.scene.position.x, view.scene.position.y)
 let size = (view.scene.frame.size.width * 0.7, view.scene.frame.size.height * 0.7)
 let ellipse = SKShapeNode (ellipseInRect: CGRectMake(center.0, center.1, size.0, size.1))
 ellipse.strokeColor = UIColor.blackColor()
 ellipse.position = CGPointMake(center)
 self.addChild(ellipse)

But it shows up in the scene like:

myscene

How do I position this in the center of the scene?

JuJoDi
  • 14,627
  • 23
  • 80
  • 126

1 Answers1

3

Instead of using

let ellipse = SKShapeNode (ellipseInRect: CGRectMake(center.0, center.1, size.0, size.1))

use

let ellipse = SKShapeNode (ellipseOfSize: CGSizeMake(size.0, size.1))

And center the sprite around

let center = (CGRectGetMidX(view.scene.frame), CGRectGetMidY(view.scene.frame))
JuJoDi
  • 14,627
  • 23
  • 80
  • 126