• Benvenuto in Making Videogames!
  • Dai sfogo alla tua fantasia!
  • Crea il tuo Videogioco!
Benvenuto ospite! Login Registrati




Valutazione discussione:
  • 0 voto(i) - 0 media
  • 1
  • 2
  • 3
  • 4
  • 5
fermare il timer
#1
Ciao, ho uno script di un timer, quando metto in pausa
il gioco il timer si ferma, ma quando tolgo la pausa il timer non riparte
da dove si era fermato.
Qualcuno mi può aiutare? Grazie.
Questo è lo script:
Codice:
public static int start = 0;
    public int time;
    public static int minutes, seconds;
    protected bool pause;

    void OnPauseGame()
    {
        this.pause = true;
    }

    void OnResumeGame()
    {
        this.pause = false;
    }

    // Use this for initialization
    void Start ()
    {

    }
    
    // Update is called once per frame
    void Update ()
    {
        if (!this.pause)
        {
            this.time = start + (int)Time.time;

            minutes = this.time / 60; //Minuti

            seconds = this.time % 60; //Secondi
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Object[] objects = FindObjectsOfType(typeof(GameObject));

            //Mette in pausa il gioco
            foreach (GameObject go in objects)
            {
                go.SendMessage("OnPauseGame", SendMessageOptions.DontRequireReceiver);
            }
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            Object[] objects = FindObjectsOfType(typeof(GameObject));

            //Mette in pausa il gioco
            foreach (GameObject go in objects)
            {
                go.SendMessage("OnPauseGame", SendMessageOptions.DontRequireReceiver);
            }
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            Object[] objects = FindObjectsOfType(typeof(GameObject));

            //Toglie la pausa
            foreach (GameObject go in objects)
            {
                go.SendMessage("OnResumeGame", SendMessageOptions.DontRequireReceiver);
            }
        }
    }
 
Rispondi
  


Messaggi in questa discussione
fermare il timer - da Bruce5000 - 18-04-2012, 07:13 PM
RE: fermare il timer - da marf - 18-04-2012, 07:54 PM

Vai al forum:


Browsing: 1 Ospite(i)