Time for action – positional audio
We create a looping positional audio node, and attach it to a parent node that is positioned at the origin.
The following sample code introduces you to a simple case of positional audio.
- Make a copy of
Main.java
and name the classPositionalSound.java
. Remember to also refactor the first line of themain()
method toPositionalSoundapp = new PositionalSound();
. - Copy the provided file
Sounds/Environment/River.ogg
into your project'sSounds/Environment/
directory. - In the
simpleInitApp()
method, attach some filler content (a node and a cube geometry) to the scene graph so you have a point of reference:public void simpleInitApp() { // Create a node for the object the sound belongs to Node riverbedNode = new Node("Riverbed"); ...
Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.