XNA 時間計時
在XNA裡面提供一個方法來計時。
int myTime = 0;
int CTime = 0;
int 計時秒 = 0;
int 計時分 = 0;
int 計時小時 = 0;


        void fun時間計時(GameTime gameTime)
        {
            this.CTime += gameTime.ElapsedGameTime.Milliseconds;
            if (this.CTime >= 1000)
            {
                this.CTime = 0;
                this.計時秒 += 1;
                if (計時秒 >= 60)
                {
                    計時秒 = 0;
                    計時分 += 1;
                    if (計時分 >= 60)
                        計時小時 += 1;
                }




                if (計時小時 > 0)
                    this.時間計時.Text = "時間計時:" + 計時小時 + "小時" + 計時分 + "分" + 計時秒 + "秒";
                else if (計時分 > 0)
                    this.時間計時.Text = "時間計時:" + 計時分 + "分" + 計時秒 + "秒";
                else
                    this.時間計時.Text = "時間計時:" + 計時秒 + "秒";
            }
        }



fun時間計時(GameTime gameTime)要寫在Update()裡面。

 

arrow
arrow
    全站熱搜

    createps 發表在 痞客邦 留言(1) 人氣()