Spritekit Scene Gets Zoomed In

I added a button to my new SKScene. It presents another scene. But whenever it presents another scene gets zoomed in. I tried


self.scene?.size = self.view!.bounds.size 


in viewDidLoad but it does not work. It's really frustrating, what may be causing th


is?

Replies

The viewDidLoad event is not triggered by changing the scenes, for that you should use didMoveToView.

Also the scene size, usually follow the SKView size, so you should resize the SKView to have the same bounds of the content.

If you are using swift, add the following in GameViewController.swift file in viewDidLoad() below let skView = self.view as! SKView


scene.size = skView.bounds.size


Hope that helps.

This is the code I use to transition from "SceneOne" to "SceneTwo"

let myScene = SceneTwo(fileNamed: "SceneTwo")
                myScene?.scaleMode = .aspectFill
                self.scene?.view?.presentScene(myScene!, transition: SKTransition.fade(withDuration: 0.5))

I use "myScene?.scaleMode = .aspectFill" to stop the zooming effect.

🙂