参数标签'(fileNamed :)'与任何可用的重载都不匹配

时间:2017-03-24 05:12:31

标签: ios swift sprite-kit

我正在尝试将场景从MenuScene转换为GameScene。我被卡在这里了。我已经完成了GameScene类,所以我不确定为什么会出现这个错误。

  override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

        for touch in touches {
            let location = touch.location(in: self)

            if atPoint(location).name == "Play" {
                let scene = GameScene(fileNamed: "GameSene") //error
                scene?.scaleMode = .aspectFill

                self.view?.presentScene(gameplay!, transition: SKTransition.doorway(withDuration: 1))

            }

            if atPoint(location).name == "Highscore" {
                scoreLabel.removeFromParent()
                createLabel()

            }}

1 个答案:

答案 0 :(得分:0)

我可以向tee重新创建此错误,当我尝试转换到的场景中有一个相应的SKS文件时,我有一个

override init(size: CGSize) {
    super.init(size: size)

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

将init更改为

override func didMove(to view: SKView)

删除

super.init

所有应该按计划工作