一个简单的倒计时程序,60s倒数到0,然后返回60s继续倒数。

 1 using UnityEngine;
 2 using System.Collections;
 3 
 4 public class Instantiate : MonoBehaviour {
 5     public float targetTime = 60f;
 6     public float currentTime = 0f;
 7     // Use this for initialization
 8     void Start () {
 9       
15     }
16     
17     // Update is called once per frame
18     void Update () {
19         FirstCutDownTime();
20 
21     }
22     ////计时器
23     void FirstCutDownTime()
24     {
25         currentTime += Time.deltaTime;
26         if(currentTime>=1f){
27             currentTime = 0f;
28             Debug.Log(targetTime);
29             targetTime -= 1f;
30             if (targetTime < 0f) {
31                 targetTime = 60f;
32             }
33         }
34     }
35 }

 

posted on 2016-09-27 19:36  奋斗的小企鹅  阅读(316)  评论(0编辑  收藏  举报