【发布时间】:2020-09-23 22:14:46
【问题描述】:
我在到达 Update 方法中的 else 语句时遇到问题,我不知道如何让这个时钟停止。 S startTime 以秒为单位。如果你做到90.0f,你将有 1.30 分钟。问题是我需要在到达0:0.0 时停止这个时钟。
public Text TimerText;
private float startTime = 3.0f;
private bool start = false;
private float _time;
private float _minutes, _seconds;
// Use this for initialization
void Start ()
{
start = false;
startTime = 3.0f;
}
// Update is called once per frame
void Update ()
{
// if (start)
// return;
if (startTime > 0.0f)
{
_time = startTime - Time.time; // ammount of time since the time has started
_minutes = (int)_time / 60;
_seconds = _time % 60;
TimerText.text = _minutes + ":" + _seconds.ToString("f1");
}
else
Debug.Log("we are here");
}
private void CheckGameOver()
{
Debug.Log("gameover");
}
public void StartTime()
{
TimerText.color = Color.black;
start = true;
}
【问题讨论】:
-
我看不到你在哪里改变
startTime