fixed Hello Audio tutorial, also updated the wiki, and added an important note about positional audio
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10713 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
82324a385e
commit
7c5571070c
@ -2,11 +2,11 @@ package jme3test.helloworld;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.audio.AudioNode;
|
||||
import com.jme3.input.MouseInput;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.shape.Box;
|
||||
|
||||
@ -27,10 +27,9 @@ public class HelloAudio extends SimpleApplication {
|
||||
flyCam.setMoveSpeed(40);
|
||||
|
||||
/** just a blue box floating in space */
|
||||
Box box1 = new Box(Vector3f.ZERO, 1, 1, 1);
|
||||
Box box1 = new Box(1, 1, 1);
|
||||
player = new Geometry("Player", box1);
|
||||
Material mat1 = new Material(assetManager,
|
||||
"Common/MatDefs/Misc/Unshaded.j3md");
|
||||
Material mat1 = new Material(assetManager,"Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat1.setColor("Color", ColorRGBA.Blue);
|
||||
player.setMaterial(mat1);
|
||||
rootNode.attachChild(player);
|
||||
@ -44,23 +43,23 @@ public class HelloAudio extends SimpleApplication {
|
||||
private void initAudio() {
|
||||
/* gun shot sound is to be triggered by a mouse click. */
|
||||
audio_gun = new AudioNode(assetManager, "Sound/Effects/Gun.wav", false);
|
||||
audio_gun.setPositional(false);
|
||||
audio_gun.setLooping(false);
|
||||
audio_gun.setVolume(2);
|
||||
rootNode.attachChild(audio_gun);
|
||||
|
||||
/* nature sound - keeps playing in a loop. */
|
||||
audio_nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", true);
|
||||
audio_nature = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", true);
|
||||
audio_nature.setLooping(true); // activate continuous playing
|
||||
audio_nature.setPositional(true);
|
||||
audio_nature.setLocalTranslation(Vector3f.ZERO.clone());
|
||||
audio_nature.setPositional(true);
|
||||
audio_nature.setVolume(3);
|
||||
rootNode.attachChild(audio_nature);
|
||||
audio_nature.play(); // play continuously!
|
||||
}
|
||||
|
||||
/** Declaring "Shoot" action, mapping it to a trigger (mouse click). */
|
||||
/** Declaring "Shoot" action, mapping it to a trigger (mouse left click). */
|
||||
private void initKeys() {
|
||||
inputManager.addMapping("Shoot", new MouseButtonTrigger(0));
|
||||
inputManager.addMapping("Shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
||||
inputManager.addListener(actionListener, "Shoot");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user