出于某种原因,当我第一次玩游戏时,一切正常,我的计时器每2秒结束一次。当我第二次再次玩时,它会每隔一秒钟做一次。
var masterTimer: NSTimer? = nil
viewDidLoad中的:
self.masterTimer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "First", userInfo: nil, repeats: true)
TimeLeft1等于2,而难度等于3
var TimeLeft1 = defaults.integerForKey("TimeLeft1")
var ScoreType = defaults.integerForKey("ScoreType")
var Difficulty = defaults.integerForKey("Difficulty")
TimeLeft1 -= 1 //take a second away
defaults.setInteger(TimeLeft1, forKey: "TimeLeft1")
if (TimeLeft1 > 0)
{
}
else
{
if Difficulty == 1 {
TimeLeft1 += 5
defaults.setInteger(TimeLeft1, forKey: "TimeLeft1")
}
else if Difficulty == 2 {
TimeLeft1 += 3
defaults.setInteger(TimeLeft1, forKey: "TimeLeft1")
}
else if Difficulty == 3 {
TimeLeft1 += 2
defaults.setInteger(TimeLeft1, forKey: "TimeLeft1")
}