How can I change a timer's delay?
Hi! I have a timer with its initial delay set at 200ms. and after some event happens I want to change it. What do I have to do to do this without creating a new timer? I am using a Swing timer.
What the timer does is repaint(), I think it should be taken into acount.
Thanks!!
Re: How can I change a timer's delay?
Have you looked at the API doc to see if the Timer class has any methods that will do what you want?
Re: How can I change a timer's delay?
Yes, there's a setDelay method, but wherever I put it, I doesn't work as I want.
Re: How can I change a timer's delay?
Do you have a small program you can post to demo your problem?
Can you explain how you want it to work.
Re: How can I change a timer's delay?
I am working on a Snake clone game. I have a timer which "moves" the snake every 200ms by changing the position of each square of the Snake, and then repaints. I want to change that delay, decrease it, when the score reaches, eg. 10, so that the snake moves faster.
Re: How can I change a timer's delay?
Quote:
I doesn't work as I want.
Can you explain what the problem is?
Can you make a small program that shows the problem?
Re: How can I change a timer's delay?
I'm so sorry! I don't know WTF happened, but now it works. I used the setDelay method, which I had already used but didn't work. I really don't know what I did wrong the other time.
Thanks for your time, anyway!!
Re: How can I change a timer's delay?
I guess its one of those mysteries.