fixed bug when playing rocket audio to not produce an AudioRender error

This commit is contained in:
Fleischer Hanno hanno.fleischer@unibw.de
2024-10-13 11:53:24 +02:00
parent 9e591e37c3
commit f8e97266d5
3 changed files with 9 additions and 16 deletions

View File

@@ -83,10 +83,10 @@ public void setEnabled(boolean enabled) {
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
this.app = (BattleshipApp) app;
shipDestroyedSound = loadSound(app, "Sound/Effects/sunken.wav", 1); //NON-NLS
splashSound = loadSound(app, "Sound/Effects/splash.wav", 2); //NON-NLS
explosionSound = loadSound(app, "Sound/Effects/explosion.wav",3); //NON-NLS
rocketSound = loadSound(app, "Sound/Effects/rocket.wav",4);
shipDestroyedSound = loadSound(app, "Sound/Effects/sunken.wav"); //NON-NLS
splashSound = loadSound(app, "Sound/Effects/splash.wav"); //NON-NLS
explosionSound = loadSound(app, "Sound/Effects/explosion.wav"); //NON-NLS
rocketSound = loadSound(app, "Sound/Effects/rocket.wav");
volume = PREFERENCES.getFloat(SOUND_VOLUME_PREF, 1.0f);
}
@@ -98,12 +98,11 @@ public void initialize(AppStateManager stateManager, Application app) {
* @param name The name of the sound file.
* @return The loaded AudioNode.
*/
private AudioNode loadSound(Application app, String name, int channel) {
private AudioNode loadSound(Application app, String name) {
try {
final AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
sound.setLooping(false);
sound.setPositional(false);
sound.setChannel(channel);
return sound;
}
catch (AssetLoadException | AssetNotFoundException ex) {