Game Development Reference
In-Depth Information
Now, add all these files to
CanyonBunny-android/assets/
. Split up the audio files
by placing them either in the
music
or
sound
subfolder. The following screenshot
shows how the final structure of your
assets
folder should look:
After this, we need to update our
Assets
class in order to make the audio files
accessible in the same way as the rest of our assets. We will also use
AssetManager
to
let LibGDX handle the loading and unloading processes of the music and sound files.
Add the following two import lines to the
Assets
class:
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
Then, add the following code to the same class:
public AssetSounds sounds;
public AssetMusic music;
public class AssetSounds {
public final Sound jump;
public final Sound jumpWithFeather;
public final Sound pickupCoin;
public final Sound pickupFeather;
public final Sound liveLost;
public AssetSounds (AssetManager am) {
jump = am.get("sounds/jump.wav", Sound.class);