Computer Science Canada Java timer while playing the game |
Author: | hamid14 [ Mon Sep 26, 2011 6:44 pm ] |
Post subject: | Java timer while playing the game |
I have a game which was made using java, its an applet. I'm trying to create a 60-second timer that gives you 60 seconds to do certain tasks in the game before it hits 0. I created a timer like this with the actionPerformed method; private Timer timer; timer = new Timer(1000,this); public void actionPerformed(ActionEvent e) { repaint(); } then i just have the actual time variable like this; time--; but the problem is, it still goes too fast, its not going down by 1 every second. How would I make it decrease every second by 1 using timer? thanks for any help. |
Author: | Zren [ Mon Sep 26, 2011 7:35 pm ] | ||
Post subject: | Re: Java timer while playing the game | ||
B will overtake A as A is doing extra calculations before waiting another second. Basically you'd have another timertask that you'd schedule for when your timer hit's zero. Also, don't forget to purge the timer when you complete the /me isn't feeling like giving the theory/hints first.
|