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

三世轮回 提交于 2019-12-11 08:33:53

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/41206712/how-do-i-get-xcode-to-run-the-code-in-gamescene-swift-instead-of-gamescene-sks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!