Results 1 to 5 of 5
  1. #1
    Kenshei is offline Member
    Join Date
    Dec 2009
    Location
    Indonesia
    Posts
    21
    Rep Power
    0

    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.. :p

    Thanks. :)

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    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!

  3. #3
    Kenshei is offline Member
    Join Date
    Dec 2009
    Location
    Indonesia
    Posts
    21
    Rep Power
    0

    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. :)

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    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!

  5. #5
    Kenshei is offline Member
    Join Date
    Dec 2009
    Location
    Indonesia
    Posts
    21
    Rep Power
    0

    Default

    Okay Then, so i can get that lesson on swing timers right.
    Thanks Fubarable.. :)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •