Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-28-2010, 02:21 PM
Member
 
Join Date: Dec 2009
Location: Indonesia
Posts: 21
Rep Power: 0
Kenshei is on a distinguished road
Lightbulb Ehm, could you help me? Thanks.
Hello everyone..

I want to make game and I wanted to create a time (60 seconds) in the middle up of the display screen size 600 x 600 ..
That time will run backwards, which is when the time is up (0), then the game will stop.
Can you help me how to make it?

Sorry if my english bad..

Thanks.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 01-28-2010, 07:34 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,449
Rep Power: 8
Fubarable is on a distinguished road
Default
The display can be a JLabel where the text is set to the time to be displayed. The Timer itself would be a Swing Timer (assuming that this is written in Swing) that repeats every second and within its actionPerformed method decrements an int class field. As for stopping the game, that will depend on your game's "model" which should have a method(s) that will allow it to be stopped.

Have a look at the tutorial, especially the one on Swing Timers and give it a go. If you run into trouble, come on back with your code.

Much luck!
__________________
When posting code, please use code tags so that your code is readable. To do this, place the tag [code] before your block of code and [/code] after your block of code.
How to use Code Tags
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-29-2010, 03:10 PM
Member
 
Join Date: Dec 2009
Location: Indonesia
Posts: 21
Rep Power: 0
Kenshei is on a distinguished road
Default
I'm sorry Fubarable, I'm new in Java, Maybe you have an example code that shows more or less the same as what you mean?

Thanks.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-29-2010, 06:56 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,449
Rep Power: 8
Fubarable is on a distinguished road
Default
The best source for sample code is the Swing tutorials. It would be far better than anything I could produce together with excellent lessons. I suggest you have a look there, study what they have on Swing Timers in particular and everything else. You'll be glad you did, and it will help you better to understand what we suggest here as well. Much luck!
__________________
When posting code, please use code tags so that your code is readable. To do this, place the tag [code] before your block of code and [/code] after your block of code.
How to use Code Tags
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-30-2010, 04:43 AM
Member
 
Join Date: Dec 2009
Location: Indonesia
Posts: 21
Rep Power: 0
Kenshei is on a distinguished road
Default
Okay Then, so i can get that lesson on swing timers right.
Thanks Fubarable..
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +2. The time now is 07:22 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org