茫茫網海中的冷日 - 對這文章發表回應
茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1675062 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_00131.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

發表限制: 非會員 可以發表

發表者: 冷日 發表時間: 2015/1/20 9:16:34
Countdown Timer

Hey I need help

I would like a timer for my game but its like a game show timer so like say you have 3 mins to complete something then when 10 secs are left the timer comes up on the screen i would like something like that but i have no idea how to do it
guitimer

check my answer on this question : http://answers.unity3d.com/questions/279434/problem-restart-time-by-key.html
and this : http://answers.unity3d.com/questions/231521/how-to-display-data-in-an-array.html
all the information you need to do this are in those 2 answers =]
also : http://lmgtfy.com/?q=unity+countdown+timer
EDIT : here is what you're after ....
    #pragma strict

    var theTimer : float = 0.0;
    var theStartTime : float = 120.0;
    var showRemaining : boolean = false;

    function Start()
    {
    theTimer = theStartTime;
    }

    function Update()
    {
    theTimer -= Time.deltaTime;

    if (theTimer < 10)
    {
    Debug.Log("TEN SECONDS LEFT !");
    showRemaining = true;
    }

    if (theTimer <= 0)
    {
    Debug.Log("OUT OF TIME");
    theTimer = 0;
    }

    if ( Input.GetKeyUp(KeyCode.G) )
    {
    Debug.Log("Resetting");
    theTimer = theStartTime;
    showRemaining = false;
    }
    }

    function OnGUI()
    {
    var text : String = String.Format( "{0:00}:{1:00}", parseInt( theTimer / 60.0 ), parseInt( theTimer % 60.0 ) );

    if (showRemaining)
    {
    GUI.Label( Rect( 10, 10, Screen.width - 20, 30), text );
    }
    }


Thats not what im looking for i have a script for a menu to come up but i need a script so it say 10 seconds left then starts counting down
Jul 21, 2012 at 10:26 PM dalekandjedi
    var showRemaining : boolean = false;

    ... in update
    if (remainingTime < 10secs)
    {
    showRemaining = true;
    }

    ... OnGUI
    if (showRemaining)
    {
    GUI.Box( Rect(0,0,100,20), remainingTime.ToString() );
    }



原文出處: Countdown Timer - Unity Answers
內容圖示
url email imgsrc image code quote
樣本
bold italic underline linethrough   












 [詳情...]
validation picture

注意事項:
預覽不需輸入認證碼,僅真正發送文章時才會檢查驗證碼。
認證碼有效期10分鐘,若輸入資料超過10分鐘,請您備份內容後,重新整理本頁並貼回您的內容,再輸入驗證碼送出。

選項

Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|