Winforms(c#)でゲームを作成していますが、進行中の時間を追跡するタイマーを作成しました。ゲームが停止するとタイマーが停止します。しかし、ゲームが停止して投稿するときにタイマーが表示する時間を節約することに成功していません。
これが私がタイマー機能を構築した方法です。
private Timer timers;
public event EventHandler Tick;
StartGame()
{
...
timers = new Timer();
timers.Interval = 1000;
timers.Tick += new EventHandler(TimerTick);
timers.Enabled = true;
}
private void TimerTick(object sender, EventArgs e)
{
Time++;
OnTick();
}
protected void OnTick()
{
if (Tick != null)
{
Tick(this, new EventArgs());
}
}