| Author |
How should i best implement this?
|
David McGratton
Greenhorn
Joined: Jul 28, 2011
Posts: 5
|
|
Hi all,
This first post contains no code, just what i want to do and asking the best way to do this. I am familiar with swing however i havent used it much.
Future posts will be my code to be approved or critised.
It involves using timers within a game.
1) An item (eg loaf_of_bread) is on the screen
2) Player picks up item, item disappears , a timer is started eg 30 seconds.
3) After 30 seconds, the timer is destroyed and the item is remade and displayed.
My thoughts are, to create an "itemManager" class containing an array of "item". The player picking up the item calls "addItemToManager(variables go here)".
The item is added to itemManager array which initiates a timer which is used to regenerate the item on the screen, based on the variables.
I am after the most effecient method to do this.
Thankyou for reading the post,
Kindest Regards.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
Then the best thing would be for you to list all the methods you have identified so far, and to evaluate each of them in terms of whatever "efficiency" means to you. You could post them here if you would like discussion about that process.
|
 |
David McGratton
Greenhorn
Joined: Jul 28, 2011
Posts: 5
|
|
Hi Paul,
This is what i have so far for me to be advised on.
Kindest Regards
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
When you need a timer in Swing, javax.swing.Timer is usually the way to go.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: How should i best implement this?
|
|
|