Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to wait a moment (.5 seconds) before I increase the sound, how can i achieve this without using Thread.sleep, because i want my game to keep runnig.

share|improve this question
When you say "increase sound" do you mean increasing the volume? This seems like a game logic problem: you just have some counter somewhere that ticks off the time then does what you want it to do. – Tetrad Mar 5 '12 at 7:20
up vote 3 down vote accepted

You can either use a java timer approach:

Or you could simply keep track of the time elapsed since the increase volume action began. Maybe something like this in your render method or somewhere else:

float elapsedTime;
long actionBeginTime;
boolean volumeIncreasing=false;
public void render () {
            increaseVolume(); //your method that increases volume
            volumeIncreasing=false; //can be set here or in increaseVolume()

Of course you need to set volumeIncreasing to true and actionBeginTime=System.nanoTime() somewhere when the action begins.

share|improve this answer
Only to add that LibGDX has its own delta value implementation (it uses System.nanoTime() internally) and you get it by calling That way you don't have to calculate by hand the elapsedTime. – arielsan Mar 6 '12 at 12:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.