Results 1 to 2 of 2

Thread: Simple timer

  1. #1
    im-not-alive is offline Member
    Join Date
    Jan 2008
    Posts
    1
    Rep Power
    0

    Default Simple timer

    I'm developing a "private server" for an online game and I'm basically reading commands from different files, example:
    Java Code:
    message = You search the crate . . .
    anim = 881
    wait = 2
    message = You find nothing.
    Theoretically what it should do is send the player a message saying "You search the crate . . .", and then a simple animation comes up and wait 2 seconds before displaying the message "You find nothing." The problem is that the delay happens at the begging of the script so it waits 2 seconds, and then it does the animation and sends both of the messages at the same time.

    This should be useful:
    Java Code:
    if(token.startsWith("wait"))
    {
    	try
    	{
    		Thread.sleep(Integer.parseInt(token3[0]) * 1000);
    	}
    	catch(Exception e)
    	{
    	}
    }
    Any help is highly appreciated; thanks in advance.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Try doing this animation and waiting inside a background thread so the EventDispatchThread is not blocked by the waiting/sleeping.

Similar Threads

  1. Replies: 0
    Last Post: 04-04-2008, 02:46 PM
  2. CountDown timer
    By Seema Sharma in forum AWT / Swing
    Replies: 1
    Last Post: 03-06-2008, 04:26 PM
  3. Page Timer
    By deeadeed in forum New To Java
    Replies: 0
    Last Post: 12-05-2007, 08:44 PM
  4. Help with timer in java
    By barney in forum Advanced Java
    Replies: 1
    Last Post: 08-01-2007, 10:24 AM
  5. problem with timer
    By Marcus in forum Advanced Java
    Replies: 2
    Last Post: 07-01-2007, 05:13 AM

Posting Permissions

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