码迷,mamicode.com
首页 > 编程语言 > 详细

unity3d---倒计时代码

时间:2017-03-08 13:04:34      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:start   down   unity   gui   imm   cond   end   private   class   

using UnityEngine;

using System.Collections;

using System;

public class Timmer : MonoBehaviour {

public GameObject countDown;

public int endTime;

public GUIText UI_Time;

public int currentTime;

public int startTime;

public int second;

public int minute;

private string printTime;

private string stringEndTime;

void Start () {

startTime = 3;

}

void Update () {

endTime = startTime - currentTime;

second = endTime % 60;

minute = endTime / 60;

currentTime = Mathf.CeilToInt(Time.fixedTime);    //开始计时

if(second<10)

{printTime = ":0";

}else{printTime = ":";}

stringEndTime =  minute + printTime + second;

print ( printTime + second);

print(stringEndTime);

UI_Time.text = stringEndTime;          //显示到游戏场景中

 

//倒计时完毕游戏结束

if(endTime<0)

{

second = 0;

minute = 0;

stringEndTime =  minute + printTime + second;     //

UI_Time.text = stringEndTime;

GameManager._instance.GameOver();                //跳转到游戏结束场景

}

 

}

}

unity3d---倒计时代码

标签:start   down   unity   gui   imm   cond   end   private   class   

原文地址:http://www.cnblogs.com/jiangyuzhen/p/6518725.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!