有人可以告诉我为什么此代码无法加载我的GameScene文件吗?

时间:2019-05-18 01:51:08

标签: ios swift sprite-kit skscene

我已经开始一个新项目并开始设置GameScene.sks文件,当我尝试运行该项目时,出现一个错误,提示它无法加载“ GameScene”文件。我已将代码与其他一些正在运行的应用程序进行了比较,但看不出代码有任何区别。我创建了一个新项目,并将代码复制到新的GameScene文件中,错误仍然出现。我不知道为什么会这样。有人请对此稍加关注,并帮助我解决这个问题。

class GameViewController: UIViewController {

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

import SpriteKit
import UIKit

class GameScene: SKScene {
    var player1 = Player(name: "Player 1", bankAccount: 1000.00)
    var player2 = Player(name: "Player 2", bankAccount: 1000.00)
    var touchedNode = SKNode()
    var touchLocation = CGPoint()
    var gameTable = SKNode()
    var gameScene = GameScene()

    var fours = SKSpriteNode()
    var fives = SKSpriteNode()
    var sixes = SKSpriteNode()
    var eights = SKSpriteNode()
    var nines = SKSpriteNode()
    var tens = SKSpriteNode()

    var foursTopBet = SKSpriteNode()
    var fivesTopBet = SKSpriteNode()
    var sixesTopBet = SKSpriteNode()
    var eightsTopBet = SKSpriteNode()
    var ninesTopBet = SKSpriteNode()
    var tensTopBet = SKSpriteNode()

    var come = SKSpriteNode()
    var dontComeBar = SKSpriteNode()
    var passLine = SKSpriteNode()
    var dontPassBet = SKSpriteNode()
    var field = SKSpriteNode()
    var hardFourBet = SKSpriteNode()
    var hardSixBet = SKSpriteNode()
    var hardEightBet = SKSpriteNode()
    var hardTenBet = SKSpriteNode()
    var snakeEyes = SKSpriteNode()
    var boxCars = SKSpriteNode()
    var anyCraps = SKSpriteNode()
    var craps3Bet = SKSpriteNode()

    override func didMove(to view: SKView) {
        setupGameTable()
    }

GameScene.sks文件的自定义类设置为“ GameScene”,模块为空白。

无法从模块'(null)'加载自定义类'GameScene'

0 个答案:

没有答案