问题
I am working on an app where there should be a red circle on the screen. At first when I tested with only one scene, the circle appeared circular just fine. However, I have added in another scene and now the circle appears like this:

The circle appears to be much longer in the x direction. Here is the code I use to make the circle (All of this in an 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)
Here is the code I use to transition to the scene with the ball (A different skscene):
func transitionToGame(){
let reveal = SKTransition.crossFadeWithDuration(1.0)
let gameOverScene = GameScene(size: self.size)
self.view?.presentScene(gameOverScene, transition: reveal)
}
Any ideas on why the ball would no longer appear as a circle? I a worried this is also going to throw off other nodes I attempt to add, and possible means the coordinate system is incorrect. I am happy to hear any ideas. Thank you!
回答1:
"All of this in an skview" are you sure you aren't doing that in a SKScene?
If the ball is indeed getting added directly to the scene I would look at the scene.scaleMode in your View Controller. Most of the time people set it to scene.scaleMode = .AspectFill
but when you create a new scene you aren't setting the scaleMode. This might be as easy as making sure both scenes have the same scaleMode.
I am guessing this will fix your issue.
func transitionToGame(){
let reveal = SKTransition.crossFadeWithDuration(1.0)
let gameOverScene = GameScene(size: self.size)
gameOverScene.scaleMode = scene.scaleMode
self.view?.presentScene(gameOverScene, transition: reveal)
}
Hopefully that helps.
来源:https://stackoverflow.com/questions/29449164/skshapenode-circle-not-appearing-circular