SKShapeNode圆圈不显示圆形

时间:2015-04-04 17:07:13

标签: ios swift sprite-kit

我正在开发一款应用,屏幕上应该有一个红圈。起初我只用一个场景进行测试时,圆圈看起来很圆。但是,我添加了另一个场景,现在圆圈显示如下: enter image description here

圆圈在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)
}

关于为什么球不再显示为圆形的任何想法?我担心这也会抛弃我试图添加的其他节点,可能意味着坐标系不正确。我很高兴听到任何想法。谢谢!

1 个答案:

答案 0 :(得分:1)

“所有这些都在skview中”你确定你没有在SKScene中这样做吗?

如果确实将球直接添加到场景中,我会查看View Controller中的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)
}

希望这有帮助。