我的遊戲應該在60s後停止。但是我的計時器代碼沒有任何反應。如何使用倒數計時器停止遊戲 - iOS [SWIFT] -
var timer = NSTimer()
var counter:Int = 60
var labelCounter:SKLabelNode = SKLabelNode()
這裏是我的GameScene類代碼:
func startTimer()
{
timer = NSTimer.scheduledTimerWithTimeInterval(1.0
, target: self, selector: Selector("updateTimer:"), userInfo: nil, repeats: true)
}
func updateTimer(dt:NSTimer)
{
counter--
if counter == 0 {
timer.invalidate()
removeCountDownTimerView()
} else{
labelCounter.text = "\(counter)"
}
}
func removeCountDownTimerView()
{
scene.view.paused = true
}
感謝您的洞察力:-)
你試過暫停現場,而不是觀點:'scene.paused = TRUE' – 2014-09-20 15:38:11