0
我的swift項目突然停止工作。它拋出了錯誤:使用未聲明的類型''Swift錯誤
使用未聲明的類型 'GameScene'
和
使用未解決的標識符的 'GameScene'
我GameViewController文件是:
class GameViewController: UIViewController {
var scene: GameScene! //Use of undeclared type 'GameScene'
override func viewDidLoad() {
super.viewDidLoad()
let skView = view as! SKView
skView.isMultipleTouchEnabled = false
scene = GameScene(size: skView.bounds.size) //Use of unresolved identifier 'GameScene'
scene.scaleMode = .aspectFill
skView.presentScene(scene)
}
我GameScene文件是:
class GameScene: SKScene {
var platform1: Platform!
override func didMove(to view: SKView) {
scene?.backgroundColor = UIColor(red: 132.0/255.0, green: 179.0/255.0, blue: 255.0/255.0, alpha: 1.0)
addPlatforms()
}
func addPlatforms() {
platform1 = Platform()
platform1.size.width = frame.size.width/4
platform1.position = CGPoint(x: platform1.width/2, y: frame.size.height/8)
addChild(platform1)
}
任何幫助將不勝感激。
您是否導入了模塊SpriteKit? –