use of com.jme3.cinematic.PlayState in project jmonkeyengine by jMonkeyEngine.
the class AbstractCinematicEvent method write.
/**
* Used for serialization only.
* @param ex exporter
* @throws IOException
*/
public void write(JmeExporter ex) throws IOException {
OutputCapsule oc = ex.getCapsule(this);
oc.write(playState, "playState", PlayState.Stopped);
oc.write(speed, "speed", 1);
oc.write(initialDuration, "initalDuration", 10);
oc.write(loopMode, "loopMode", LoopMode.DontLoop);
}
use of com.jme3.cinematic.PlayState in project jmonkeyengine by jMonkeyEngine.
the class Cinematic method setTime.
/**
* This is used internally but can be called to shuffle through the
* cinematic.
*
* @param time the time to shuffle to.
*/
@Override
public void setTime(float time) {
//stopping all events
onStop();
super.setTime(time);
int keyFrameIndex = timeLine.getKeyFrameIndexFromTime(time);
//then computing timeOffset for each event
for (int i = 0; i <= keyFrameIndex; i++) {
KeyFrame keyFrame = timeLine.get(i);
if (keyFrame != null) {
for (CinematicEvent ce : keyFrame.getCinematicEvents()) {
float t = this.time - timeLine.getKeyFrameTime(keyFrame);
if (t >= 0 && (t <= ce.getInitialDuration() || ce.getLoopMode() != LoopMode.DontLoop)) {
ce.play();
}
ce.setTime(t);
}
}
}
lastFetchedKeyFrame = keyFrameIndex;
if (playState != PlayState.Playing) {
pause();
}
}
use of com.jme3.cinematic.PlayState in project jmonkeyengine by jMonkeyEngine.
the class AbstractCinematicEvent method read.
/**
* Used for serialization only.
* @param im importer
* @throws IOException
*/
public void read(JmeImporter im) throws IOException {
InputCapsule ic = im.getCapsule(this);
playState = ic.readEnum("playState", PlayState.class, PlayState.Stopped);
speed = ic.readFloat("speed", 1);
initialDuration = ic.readFloat("initalDuration", 10);
loopMode = ic.readEnum("loopMode", LoopMode.class, LoopMode.DontLoop);
}
Aggregations