I'm sorry I do not have any code yet, because I have no clue how to do this, but I have a game and you can select amount of time to play the game for and I want to display a timer with the amount fo time you have left. The timer currently will just end the game and display a messagebox when the time is out.
Thanks in advance for the help.
Matt.
Countdown TimerCountdown Timer
Page 1 of 1
4 Replies - 1195 Views - Last Post: 29 January 2009 - 11:03 AM
Replies To: Countdown Timer
#3
Re: Countdown Timer
Posted 29 January 2009 - 10:50 AM
wailedekim, on 29 Jan, 2009 - 10:35 AM, said:
I'm sorry I do not have any code yet, because I have no clue how to do this, but I have a game and you can select amount of time to play the game for and I want to display a timer with the amount fo time you have left. The timer currently will just end the game and display a messagebox when the time is out.
Thanks in advance for the help.
Matt.
Thanks in advance for the help.
Matt.
To display a Timer in a Label you need to declare an integer and set its value equal to the time you want to start off with. After that you need to make a timer and set the interval to 1000, this will equal 1 second, afterwards in the Timer tick event you will need to do this.
Dim GameTime as Integer = 90 'the time you want to start the game off as Private Sub tmrTotalTime_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrTotalTime.Tick GameTime -= 1 'will decrease the Integer by 1 every second lblGameTime.Text = GameTime.ToString End Sub
To end the game just use an if statement to check to see if GameTime equals 0 and put the correct code that follows
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|