I'm trying to translate SKScene * scene = [GameScene sceneWithSize:skView.bounds.size];
into swift but I get the error
'sceneWithSize' is unavailable: use object construction 'SKScene(size:)'.
I am using viewWillLayoutSubviews
and cutting out the viewDidLoad()
because it does not give correct dimensions for the screen dimensions of the device I choose. It actually makes me question 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)
}
}