using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
private float allTime = 10.999f;
private int showNumber;
private bool gameOver = false;
private bool isBegin = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
showNumber = (int)allTime;
if (allTime > 0) {
if(isBegin){
allTime -= Time.deltaTime;
}
}else{
gameOver = true;
}
}
void OnGUI(){
GUI.Button (new Rect (10, 10, 100, 100), showNumber+"");
if (GUI.Button (new Rect (120, 10, 100, 100), "开始计时")) {
isBegin = true;
}
if (gameOver) {
GUI.Button(new Rect(Screen.width/2-50,Screen.height/2-50,100,100),"游戏结束");
}
}
}
一个思路
在update里累计每帧时间就行了
float?i=90f;
void?start()
{
?????debug.log("倒计时"+i.tostring()+"秒");
}
void?update()
{
i-=time.delttime;
if(1<=0) ????debug.log("倒计时时间到");="">=0)>
Photoshop|
Dreamweaver|
SVG|
WebGL|
Visual Studio|
PowerDesigner|
Eclipse|
Git|
Apache Ant|
Atom|
Composer|
CodeSmith|
Flex|
Gradle|
Maven|
Sublime Text3|
SVN|
Tableau|
Vim|
Chrome开发者工具|
OpenGL|
Unity|
Direct3D|
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....