finished 12

This commit is contained in:
Cedric Beck
2024-10-08 14:22:42 +02:00
parent 5edd4ebe0b
commit 4492843ca1
19 changed files with 350 additions and 52 deletions

View File

@@ -0,0 +1,37 @@
package pp;
import com.jme3.app.Application;
import com.jme3.asset.AssetLoadException;
import com.jme3.asset.AssetNotFoundException;
import com.jme3.audio.AudioData;
import com.jme3.audio.AudioNode;
import pp.util.Util;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
public class JmeUtil {
private JmeUtil(){ /* Do not initialize */ }
private static final Logger LOGGER = System.getLogger(Util.class.getName());
/**
* Loads a sound from the specified file.
*
* @param app The application
* @param name The name of the sound file.
* @return The loaded AudioNode.
*/
public static AudioNode loadSound(Application app, String name) {
try {
final AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
sound.setLooping(false);
sound.setPositional(false);
return sound;
}
catch (AssetLoadException | AssetNotFoundException ex) {
LOGGER.log(Level.ERROR, ex.getMessage(), ex);
}
return null;
}
}