🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
a timer for pauses in my game in java.
I need to know how to do a time pause sorta thing in java for my game. I need it for a pause for my logo, and of course to have a timer in the game maybe like 3 minutes for each level, or something. I've tried the Thread.sleep(3000), but it literally just stops with or without a try and catch method. Do anyone here know how to do this? I'd really appreciate it.
Thanks,
c.s. finch
You probably want something like this:
long start = System.currentTimeMillis();while (System.currentTimeMillis() < start + 3000);
Quote: Original post by scgrn
You probably want something like this:long start = System.currentTimeMillis();while (System.currentTimeMillis() < start + 3000);
Thanks, I'll give it a shot!
Actually, I thought this would work, but it doesn't maybe you can see my error.
I have a long var named start_time
start_time = System.currentTimeMillis();
then I have this code here
while(System.currentTimeMillis() < start_time + 3000)
{
gfx.drawImage(logo, getSize().width/2 - 150, getSize().height - 30, this)
}
gfx.fillRec(0,0,getSize().width,getSize().height)
gfx.drawImage(menu, 0,0, this);
but it just waits 3 seconds+ during loading the java applet then draws my menu instead of what I want it to do. Why is this not working the way I want it to work?
I want there to be about a 3 second pause for my logo then the menu shows up and that's it. Well, I'll work on it tonight until I get it right.
Machs gut!
c.s. finch
I have a long var named start_time
start_time = System.currentTimeMillis();
then I have this code here
while(System.currentTimeMillis() < start_time + 3000)
{
gfx.drawImage(logo, getSize().width/2 - 150, getSize().height - 30, this)
}
gfx.fillRec(0,0,getSize().width,getSize().height)
gfx.drawImage(menu, 0,0, this);
but it just waits 3 seconds+ during loading the java applet then draws my menu instead of what I want it to do. Why is this not working the way I want it to work?
I want there to be about a 3 second pause for my logo then the menu shows up and that's it. Well, I'll work on it tonight until I get it right.
Machs gut!
c.s. finch
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement