5

Quite recently I have had a craze to make simple small scale games on Java. I have been using the Swing Timer class for all of my animations and such, and was wondering how bad would it be to be using multiple timers at once.

How would this affect the program? and if not the program is it intensive on a CPU? On small scale games I would guess it wouldnt have a great affect, but how bad could it get if its a large scale multiplayer RPG game for example?

If i wish for things to happen at different "frequencies" is it possible to do it in a single timer?

For example: Im playing the game and using my Timer timer for all my animations and repainting of the screen. As the game ends, I wish to show the number of coins i gathered during the whole game in an "incrementing animation". Of course as the game ends i have to end my timer! So to show this last end game coin gathered animation, i would have to have another Timer timer2....

Shrey
  • 671
  • 7
  • 14

1 Answers1

1

Although it is more difficult to understand if you've used timers extensively in the past, I recommend that you move to using Java's executor service. If you would like to know some of the differences between timer and executor service, the following is a good summary:

Java Timer vs ExecutorService?

Especially in games when dealing with multiple threads, the executor service is indispensable.

Community
  • 1
  • 1