我一直试图这样做很长一段时间。我的问题是,当我使用此代码时(我在YouTube上了解到),它在第5行给出了一个错误,它声明了SKView
。它
给我这个错误
来自SKView的垂头丧气?'到' SKView'只打开选项;你是否 意思是使用'!'?
这是我的代码:
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
/* Called when a touch begins */
//making the scene vars
var scene = PlayScene(size: self.size)
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
let node = self.nodeAtPoint(location)
var scene = PlayScene(size: self.size)
let skView = self.view as SKView
skView.ignoresSiblingOrder = true
scene.scaleMode = .ResizeFill
scene.size = skView.bounds.size
skView.presentScene(scene)
}
}
答案 0 :(得分:1)
替换此行:
let skView = self.view as SKView
这一行:
let skView = self.view!