Reputation: 885
Similar to this question, I'm trying to change the initial scene of my game to FirstScene.swift
.
I changed the following in GameViewController.swift
:
from:
override func viewDidLoad() {
super.viewDidLoad()
if let view = self.view as! SKView? {
// Load the SKScene from 'GameScene.sks'
if let scene = SKScene(fileNamed: "GameScene") {
// Set the scale mode to scale to fit the window
scene.scaleMode = .aspectFill
// Present the scene
view.presentScene(scene)
}
view.ignoresSiblingOrder = true
view.showsFPS = true
view.showsNodeCount = true
}
}
to:
if let scene = SKScene(fileNamed: "FirstScreen")
FirstScreen.swift starts with
import SpriteKit
class FirstScreen: SKScene, SKPhysicsContactDelegate {
Also tried :
if let scene = FirstScreen(fileNamed: "FirstScreen")
I've also tried a new project and still no luck! Any ideas please?
Upvotes: 0
Views: 360
Reputation: 2459
Do it this way:
let scene = FirstScene()
scene.scaleMode = .aspectFill
view.presentScene(scene)
Note that the SKScene(fileNamed: String)
constructor is used to unarchive a scene from a .sks
file.
I am assuming you do not have a FirstScene.sks
file in your project.
Upvotes: 1