0
所以顯然GameScene不能.presentViewController,所以這就是我所做的。在Gamescene中顯示UIAlertViewController?
let msg="Congrats... You died!\n"+"Score: "+String(score)
let myAlert: UIAlertController = UIAlertController(title: msg, message: "Try Again?", preferredStyle: .Alert)
let okAction = UIAlertAction(title: "Play Again", style: UIAlertActionStyle.Default) {
UIAlertAction in
self.timer.invalidate() //timer is not properly invalidating... it multple bacteria spawn... eevery 10 seconds with t difference ~0.5 seconds <-- FIXED as of 2/29/16
self.timer=NSTimer.scheduledTimerWithTimeInterval(10, target: self, selector: Selector("spawnBacteria"), userInfo: nil, repeats: true)
self.spawnBacteria()
score=0
// print("FIRE")
}
myAlert.addAction(okAction)
// _______________
self.view?.window?.rootViewController?.presentViewController(myAlert, animated: true, completion: nil)
但是,看來這並不多視圖的工作,我想補充另一種觀點爲我的遊戲的菜單。那麼,我該如何創建這個UIAlertViewController並將其添加到GameScene中呢?任何幫助深表感謝。 注意:我知道提出了一個相同的問題,但我不明白答案,並且我不知道應該在答案中提供哪些代碼片段,因此請不要忽略此問題。謝謝