I have been trying to do this for a long time. My problem is when I use this code (I learned of on YouTube), it gives me an error on line 5 where it declares the SKView
. It gives me this error
Downcast from 'SKView?' to 'SKView' only unwraps optionals; did you mean use '!'?
Here is my code:
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)
}
}
Replcace this line:
let skView = self.view as SKView
with this line:
let skView = self.view!
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加