SKShapeNode Circle 没有出现圆形

SKShapeNode Circle not appearing circular

我正在开发一个应用程序,屏幕上应该有一个红色圆圈。起初,当我只测试一个场景时,圆圈呈圆形就好了。但是,我添加了另一个场景,现在圆圈是这样的:

圆似乎在 x 方向上更长。 这是我用来制作圆圈的代码(所有这些都在一个 skscene 中):

    let ball = Ball(circleOfRadius: 500)//ball is a subclass of SKShapeNode
    ball.setScale((self.frame.height / 6) / 1000)            
    ball.position = CGPointMake(self.frame.width / 4, self.frame.height / 2)
    ball.fillColor = UIColor.redColor()
    ball.strokeColor = UIColor.clearColor()
    self.addChild(ball)

这是我用来转换到带球场景的代码(一个不同的 skscene):

func transitionToGame(){
    let reveal = SKTransition.crossFadeWithDuration(1.0)
    let gameOverScene = GameScene(size: self.size)
    self.view?.presentScene(gameOverScene, transition: reveal)
}

关于球不再显示为圆圈的原因有什么想法吗?我担心这也会影响我尝试添加的其他节点,并且可能意味着坐标系不正确。我很高兴听到任何想法。谢谢!

"All of this in an skview" 你确定你不是在 SKScene 中这样做吗?

如果球确实被直接添加到场景中,我会查看您的视图控制器中的 scene.scaleMode。大多数时候,人们将其设置为 scene.scaleMode = .AspectFill,但当您创建新场景时,您并没有设置 scaleMode。这可能就像确保两个场景具有相同的 scaleMode 一样简单。

我猜这会解决您的问题。

func transitionToGame(){
    let reveal = SKTransition.crossFadeWithDuration(1.0)
    let gameOverScene = GameScene(size: self.size)
    gameOverScene.scaleMode = scene.scaleMode
    self.view?.presentScene(gameOverScene, transition: reveal)
}

希望对您有所帮助。