I have an SKScene, where I use an SKSpriteNode as the background. While the work I do below to make it fit to scale isn't much, I wondered if Swift provided a method or property that would do the same?
From my GameScene
From my main ViewController, where I create the GameScene
From my GameScene
Code Block override func didMove(to view: SKView){ super.didMove(to: view) self.backgroundColor = .clear let ratio = self.size.height / background.size.height background.size.height *= ratio background.size.width *= ratio background.anchorPoint = CGPoint(x: 0.0, y: 0.0) background.zPosition = -1 addChild(background) physicsWorld.contactDelegate = self self.isHidden = true
From my main ViewController, where I create the GameScene
Code Block let scene = WheelScene(size: myView.frame.size) scene.anchorPoint = CGPoint(x: 0.0, y: 0.0) scene.backgroundColor = .clear scene.scaleMode = .aspectFit wheelScene = scene mainView = myView myView.presentScene(wheelScene)