Timer

Forum for J2ME mobile games related topics including programming doubts, books and other resources for J2ME game development

Timer

Postby samsonite » Fri Apr 04, 2008 9:08 am

Hi,
I have included a timer in the game.Time limit is 3 min.
It starts from 2.60.60 and continues till 0.60.60
But as soon as it reaches 0.60.60,timer stops and it becomes
0.0.0.
I don't know how is it happening?
plz make this code working so dat the timer starts from 2.60.60 and continues till
0.0.0
I am giving the code here....

//......TIMER.............
if(Timer==true)
{
if(min>=0)
{
if(ms==0)
{
ms=60;

if(sec==0)
{
sec=60;
min--;
}
else
{
sec--;
}

}
else if(ms>0)
{
ms-=10;
}


}
else
{

}


time = min + ":" +sec+ ":" + ms;

}
samsonite
 
Posts: 1
Joined: Fri Apr 04, 2008 8:57 am

Re: Timer

Postby DevelopmentTeam » Mon Apr 07, 2008 12:34 pm

Whenever you are going to work with time better user System.currentTimeMillis() and do the canculations. Dont convert the time to hours, mins and seconds. always have it in seconds. :)
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India


Return to J2ME Games

Who is online

Users browsing this forum: No registered users and 2 guests

cron