Failed Counter Code

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

Failed Counter Code

Postby johnsearle » Wed Oct 10, 2012 5:57 am

I'm attempting to write a simple test app that counts down by the second and displays it on the screen. I have used the following to get my current results:

Code: Select all
      Time currentTime = new Time();
      int milliDiff = (int) (currentTime.toMillis(false) - startTime.toMillis(false));
      if(milliDiff > 1000) {
         sec--; // in class scope to count # seconds
         millis = milliDiff;
         if(sec < 0) {
            sec = 0;
         } else if (sec < 10) {

The display code is elsewhere, and the FPS < 1 second. If I set the value of milliDiff to 500, then it seems to run at close to the proper speed.

I know there are other approaches to this problem, but can anyone explain why this fails?

Once Poster
Once Poster
Posts: 1
Joined: Wed Oct 10, 2012 5:49 am


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests