Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Countdown Timer 1

Status
Not open for further replies.

civilwar123456

Programmer
Jun 6, 2005
7
CY
I already found some threads about this, but i couldnt get the help i wanted out of them. I'm workin on a game and i want to add a a countdown timer (let's say for example 3 minutes) but to show up as minutes ("3:00") till 0:00. The game is divided by phases, so i wanna put a timer for each phase. Any help would be apreciated :) Thank you.
 
There are many ways to do this, but here's one example. Attach this behaviour to a text sprite - it displays "3:00" down to "0:00":
[tt]--
on beginSprite me
sprite(me.spriteNum).member.text = "3:00"
startTimer()
end beginSprite

on enterFrame me
tSecElapsed = (the timer)/60
if tSecElapsed < 180 then
tTime = 180 - tSecElapsed
tSec = tTime mod 60
if tSec < 10 then
tSec = "0" & tSec
end if
tMin = tTime/60
sprite(me.spriteNum).member.text = tMin & ":" & tSec
else
sprite(me.spriteNum).member.text = "0:00"
end if
end enterFrame
--[/tt]

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top