finished 12
This commit is contained in:
37
Projekte/jme-common/src/main/java/pp/JmeUtil.java
Normal file
37
Projekte/jme-common/src/main/java/pp/JmeUtil.java
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user