首页 > 其他 > 详细

一个简单的游戏倒计时

时间:2016-09-27 20:14:33      阅读:140      评论:0      收藏:0      [点我收藏+]

 

一个简单的倒计时程序,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 }

 

一个简单的游戏倒计时

原文:http://www.cnblogs.com/-zeus/p/5914010.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!