hey im trying to create a time counter to show how long the player has been alive for
can anyone help?


1 2 3 4 5 6 7 8 9 | // When the game is started, do: long startTime = System.currentTimeMillis(); // Later (for example in an act() method), do: long currentTime = System.currentTimeMillis(); int durationMillis = ( int )(currentTime - startTime); // durationMillis is in milliseconds, so you // can convert to seconds/minutes whatever: int durationSecs = durationMillis / 1000 ; |