Playing sounds on events
The last thing that remains to be done to make the events feel more lively and real is to add sounds. We have prepared two sounds that we will play.
Just to refresh our memories, this is how we loaded the sounds in the ResourceManager
class:
public class ResourceManager { ... //sounds public Sound soundFall; public Sound soundJump; ... public void loadGameAudio() { try { SoundFactory.setAssetBasePath("sfx/"); soundJump = SoundFactory.createSoundFromAsset(activity.getSoundManager(), activity, "jump.ogg"); soundFall = SoundFactory.createSoundFromAsset(activity.getSoundManager(), activity, "fall.ogg"); MusicFactory.setAssetBasePath("mfx/"); music = MusicFactory.createMusicFromAsset(activity.getMusicManager(), activity, "music.ogg"); } catch (Exception e) { throw new RuntimeException("Error while loading audio", e); } } ... }
Playing the jump sound
The jump sound should happen on the player-platform...