Timer for game

Put your problem here if it does not fit any of the other categories.

Timer for game

Postby Shweta » Wed Nov 10, 2010 9:16 am

Hi.. i m new to android.. I want to display a timer at the bottom of the page which starts with the first click and ends when game finishes.
Please guide..
Shweta
Junior Developer
Junior Developer
 
Posts: 15
Joined: Tue Oct 26, 2010 8:45 am

Top

Re: Timer for game

Postby mrjohs » Wed Nov 10, 2010 9:40 am

Use System.currentTimeMillis() to get milliseconds since 1/1/1970. If you, for example, have one variable which holds the time the user started playing, and for each frame subtract that variable from currentTimeMillis(), you will have the time in milliseconds since the user started playing.

Use google or your math skills to convert those milliseconds to minutes, seconds, or whatever you want.
Apploudable - Entertainment apps for the Android platform
http://apploudable.com
mrjohs
Freshman
Freshman
 
Posts: 8
Joined: Fri Oct 01, 2010 3:42 pm

Re: Timer for game

Postby Shweta » Wed Nov 10, 2010 10:01 am

Thanks :)
Shweta
Junior Developer
Junior Developer
 
Posts: 15
Joined: Tue Oct 26, 2010 8:45 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 20 guests