大佬教程收集整理的这篇文章主要介绍了如何使用倒数计时器来停止游戏 – iOS [SWIFT] –,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
var timer = NSTimer() var counter:Int = 60 var labelCounter:SKLabelNode = SKLabelNode()
这是我的GameScene类中的@L_772_0@:
func startTimer() { timer = NSTimer.scheduledTimerWithTimeInterval(1.0,target: self,SELEctor: SELEctor("updatetiR_577_11845@er:"),userInfo: nil,repeats: truE) } func updatetiR_577_11845@er(dt:NSTimer) { counter-- if counter == 0 { timer.invalidate() removeCountDownTimerView() } else{ labelCounter.text = "\(counter)" } } func removeCountDownTimerView() { scene.view.paused = true }
感谢您的见解 :-)
override func viewDidLoad() { super.viewDidLoad() //calling the wait function self.callForWait() } func callForWait(){ //setTing the delay time 60secs. let delay = 60 * Double(NSEC_PER_SEC) let time = dispatch_time(DISPATCH_TIME_Now,Int64(delay)) dispatch_after(time,dispatch_get_main_queue()) { //call the method which have the steps after delay. self.stepsAfterDelay() } } func stepsAfterDelay(){ //your code after delay takes place here... }
以上是大佬教程为你收集整理的如何使用倒数计时器来停止游戏 – iOS [SWIFT] –全部内容,希望文章能够帮你解决如何使用倒数计时器来停止游戏 – iOS [SWIFT] –所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。