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!

timer count down problem

Status
Not open for further replies.

00755

Programmer
Mar 31, 2005
6
0
0
GB
am using this code beloew: but when i run it i can not get it to count down for 30 sec, instead i get like -5945 :S any help would be very grateful

cheers chris

global gEndTime


on startMovie

-- game ends 30 seconds from now
gEndTime = the ticks + 30*60


showTime
end

on showTime
-- convert ticks to seconds remaining
timeLeft = (gEndTime - the ticks + 30)/60

-- use this text
text = "Time:"&&timeLeft

-- if text is different than text displayed
if member("Time").text <> text then
member("Time").text = text
end if

-- time up?
if timeLeft <= 0 then
go to frame "gameover"
end if
end
 
Your script works just fine. I'd place "showTime" event in the frame loop so the display will be updated, something like:
--
on exitFrame me
showTime
go the frame
end
--
Also I wouldn't use "text" as a variable name as "text" is predefined property name in Lingo: you (or Director) will get confused otherwise!

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top