import com.jme3.export.JmeImporter;
import com.jme3.export.OutputCapsule;
import com.jme3.system.NanoTimer;
+import com.jme3.system.Timer;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
protected float initialDuration = 10;
protected LoopMode loopMode = LoopMode.DontLoop;
protected float time = 0;
- //nano timer for precisely computing the elapsed time
- protected NanoTimer timer;
+ protected Timer timer;
+ protected float start = 0;
/**
* the last time the event was paused
*/
onPlay();
playState = PlayState.Playing;
if (timer == null) {
+ //only when used as a control
timer = new NanoTimer();
}
- timer.reset();
+ start = timer.getTimeInSeconds();
+ //timer.reset();
if (listeners != null) {
for (int i = 0; i < listeners.size(); i++) {
CinematicEventListener cel = listeners.get(i);
*/
public void internalUpdate(float tpf) {
if (playState == PlayState.Playing) {
- time = (elapsedTimePause + timer.getTimeInSeconds()) * speed;
+ time = (elapsedTimePause + timer.getTimeInSeconds() - start) * speed;
onUpdate(tpf);
if (time >= initialDuration && loopMode == loopMode.DontLoop) {
* @param cinematic
*/
public void initEvent(Application app, Cinematic cinematic) {
- timer = new NanoTimer();
+ timer = app.getContext().getTimer();
+ //timer = new NanoTimer();
}
/**
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.Control;
-import com.jme3.system.NanoTimer;
import java.io.IOException;
/**
public void initEvent(Application app, Cinematic cinematic) {
super.initEvent(app, cinematic);
isControl = false;
- timer = null;
+ // timer = null;
}
public void onUpdate(float tpf) {