@Override public void simpleUpdate(float tpf) { time += tpf; if (time > 1f) { audioSource.playInstance(); time = 0; } }
@Override public void onAction(String name, boolean keyPressed, float tpf) { if (name.equals("Shoot") && !keyPressed) { audio_gun.playInstance(); // play each instance once! } } };
/** * Internal use only * * @see Track#setTime(float, float, com.jme3.animation.AnimControl, * com.jme3.animation.AnimChannel, com.jme3.util.TempVars) */ public void setTime(float time, float weight, AnimControl control, AnimChannel channel, TempVars vars) { if (time >= length) { return; } if (!initialized) { control.addListener(new OnEndListener()); initialized = true; } if (!started && time >= startOffset) { started = true; audio.playInstance(); } }
public void play() { if (fileName != null){ if (node != null){ node.stop(); } node = new AudioNode(am, fileName,AudioData.DataType.Stream); node.setPositional(false); node.setVolume(volume); node.play(); }else{ node.playInstance(); } }
@Override public void simpleUpdate(float tpf) { time += tpf; if (time > nextTime) { Vector3f v = new Vector3f(); v.setX(FastMath.nextRandomFloat()); v.setY(FastMath.nextRandomFloat()); v.setZ(FastMath.nextRandomFloat()); v.multLocal(40, 2, 40); v.subtractLocal(20, 1, 20); audioSource.setLocalTranslation(v); audioSource.playInstance(); time = 0; nextTime = FastMath.nextRandomFloat() * 2 + 0.5f; } } }
nature.setVolume(3); waves.playInstance(); nature.play();
/** * Internal use only * * @see Track#setTime(float, float, com.jme3.animation.AnimControl, * com.jme3.animation.AnimChannel, com.jme3.util.TempVars) */ public void setTime(float time, float weight, AnimControl control, AnimChannel channel, TempVars vars) { if (time >= length) { return; } if (!initialized) { control.addListener(new OnEndListener()); initialized = true; } if (!started && time >= startOffset) { started = true; audio.playInstance(); } }
/** * Internal use only * * @see Track#setTime(float, float, com.jme3.animation.AnimControl, * com.jme3.animation.AnimChannel, com.jme3.util.TempVars) */ public void setTime(float time, float weight, AnimControl control, AnimChannel channel, TempVars vars) { if (time >= length) { return; } if (!initialized) { control.addListener(new OnEndListener()); initialized = true; } if (!started && time >= startOffset) { started = true; audio.playInstance(); } }