Sprite Kit场景切换Xcode 7

时间:2016-01-10 21:59:32

标签: ios xcode sprite-kit

我正在尝试从GameScene到Title场景进行简单的场景切换,但我一直收到错误:"线程1:EXC_BAD_INSTRUCTION(代码= EXC_1386_INVOP,子代码= 0x0)"在线上                  skView.presentScene(titleScene !, transition:transition)

我该如何解决这个问题?

import SpriteKit

let playButton = SKSpriteNode(imageNamed: "Spaceship")

class GameScene: SKScene {
override func didMoveToView(view: SKView) {
    playButton.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMaxY(self.frame))
    self.addChild(playButton)
}

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


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


        if playButton.containsPoint(location) {
            let titleScene = TitleScene(fileNamed: "TitleScene")
            let transition = SKTransition.fadeWithDuration(0.5)
            let skView = self.view as SKView!
            skView.ignoresSiblingOrder = true
            titleScene?.scaleMode = .AspectFill
            skView.presentScene(titleScene!, transition: transition)


        }
    }


}

}

0 个答案:

没有答案