我想要在场景中心绘制一个椭圆
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)
但它出现在场景中:
如何将其置于场景的中心?
答案 0 :(得分:3)
而不是使用
let ellipse = SKShapeNode (ellipseInRect: CGRectMake(center.0, center.1, size.0, size.1))
使用
let ellipse = SKShapeNode (ellipseOfSize: CGSizeMake(size.0, size.1))
围绕精灵的中心
let center = (CGRectGetMidX(view.scene.frame), CGRectGetMidY(view.scene.frame))