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;
}
Time.deltaTime
대신 사용 Time.time
하고 변경하십시오.
if (_time> 0.0f)
{...}
추가 _time = startTime
로Start()
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다