How do I get xcode to run the code in GameScene.swift instead of GameScene.sks

373 Views Asked by At

How is it possible to get xcode to run the code inside of the GameScene.swift instead of GameScene.sks?

1

There are 1 best solutions below

3
On BEST ANSWER

Everything is in GameViewController

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
 }

you can change it by replacing with this code

if let view = self.view as! SKView? {
    let scene = GameScene(size: view.bounds.size)

    // 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
}

it will run the code in GameScene.swiftinstead of the code in GameScene.sks. so you can create the nodes by code.