I try to translate SKScene * scene = [GameScene sceneWithSize:skView.bounds.size];
in swift, but getting an error
'sceneWithSize' is not available: use the object construct 'SKScene (size :)'.
I use viewWillLayoutSubviews
and viewDidLoad()
because it does not give the correct sizes for the screen sizes of the device that I select. This really makes me wonder why viewDidLoad()
exists at all?
override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews(); let skView = self.view as SKView; if skView.scene != nil { skView.showsFPS = true; skView.showsNodeCount = true; skView.showsPhysics = true; // Create and configure the scene let scene:SKScene = GameScene.sceneWithSize(skView.bounds.size); // ERROR MESSAGE! // Objective-C code in next 2 lines // SKScene * scene = [GameScene sceneWithSize:skView.bounds.size]; // scene.scaleMode = SKSceneScaleModeAspectFill; // Present Scene skView.presentScene(scene) } }
source share