问题
The Sound API seems to be missing a function to indicate that a sound is finished playing. Is there some other way of finding out if the sound is done?
回答1:
Not without submitting a patch to libgdx as far as I know the underlying Sound Backends for both OpenAL and Android don't even track the information internally, though the Music API has an isPlaying() function and getPosition() function as per the documentation.
回答2:
just set this
sound.setLooping(false);
this way it will not run again and again.
and to check whether sound is playing or not do this.
make a boolean variable
boolean soundplaying;
in render method do this
if(sound.isPlaying()){
soundplaying =true
}
and make a log
gdx.app.log("","sound"+soundplaying);
来源:https://stackoverflow.com/questions/11704733/libgdx-how-can-i-tell-when-a-sound-has-finished-playing