public abstract class AbstractCinematicEvent extends java.lang.Object implements CinematicEvent
Modifier and Type | Field and Description |
---|---|
protected float |
initialDuration |
protected java.util.List<CinematicEventListener> |
listeners
The list of listeners.
|
protected LoopMode |
loopMode |
protected PlayState |
playState |
protected boolean |
resuming |
protected float |
speed |
protected float |
time |
Constructor and Description |
---|
AbstractCinematicEvent()
Construct a cinematic event (empty constructor).
|
AbstractCinematicEvent(float initialDuration)
Construct a cinematic event with the given initial duration.
|
AbstractCinematicEvent(float initialDuration,
LoopMode loopMode)
Construct a cinematic event with the given loopMode and the given initialDuration.
|
AbstractCinematicEvent(LoopMode loopMode)
Construct a cinematic event with the given loopMode.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(CinematicEventListener listener)
Add a CinematicEventListener to this event.
|
void |
dispose()
method called when an event is removed from a cinematic
this method should remove any reference to any external objects.
|
void |
forceStop()
Implement this method if the event needs different handling when
stopped naturally (when the event reach its end),
or when it was force-stopped during playback.
|
float |
getDuration()
Returns the actual duration of the animation (initialDuration/speed)
|
float |
getInitialDuration()
Returns the initial duration of the animation at speed = 1 in seconds.
|
LoopMode |
getLoopMode()
Returns the loopMode of the animation.
|
PlayState |
getPlayState()
Returns the current playstate of the animation (playing or paused or stopped).
|
float |
getSpeed()
Returns the speed of the animation.
|
float |
getTime()
Return the current timestamp of the event.
|
void |
initEvent(Application app,
Cinematic cinematic)
Initialize this event (called internally only).
|
void |
internalUpdate(float tpf)
Used internally only.
|
abstract void |
onPause()
Implement this method with code that you want to execute when the event is paused.
|
protected abstract void |
onPlay()
Implement this method with code that you want to execute when the event is started.
|
protected abstract void |
onStop()
Implement this method with code that you want to execute when the event is stopped.
|
protected abstract void |
onUpdate(float tpf)
Implement this method with the code that you want to execute on update
(only called when the event is playing).
|
void |
pause()
Pause this event.
|
void |
play()
Play this event.
|
void |
read(JmeImporter im)
Used for serialization only.
|
void |
removeListener(CinematicEventListener listener)
Remove a CinematicEventListener from this event.
|
void |
setInitialDuration(float initialDuration)
Sets the duration of the animation at speed = 1 in seconds.
|
void |
setLoopMode(LoopMode loopMode)
Sets the loopMode of the animation.
|
void |
setSpeed(float speed)
Sets the speed of the animation.
|
void |
setTime(float time)
Fast-forward the event to the given timestamp.
|
void |
stop()
Stops the animation.
|
void |
write(JmeExporter ex)
Used for serialization only.
|
protected PlayState playState
protected LoopMode loopMode
protected float initialDuration
protected float speed
protected float time
protected boolean resuming
protected java.util.List<CinematicEventListener> listeners
public AbstractCinematicEvent()
public AbstractCinematicEvent(float initialDuration)
initialDuration
- the desired duration (in seconds, default=10)public AbstractCinematicEvent(LoopMode loopMode)
loopMode
- the desired mode (Loop/DontLoop/Cycle)public AbstractCinematicEvent(float initialDuration, LoopMode loopMode)
initialDuration
- the duration of the event at speed = 1.loopMode
- the loop mode of the event.public void forceStop()
forceStop
in interface CinematicEvent
public void play()
play
in interface CinematicEvent
protected abstract void onPlay()
public void internalUpdate(float tpf)
internalUpdate
in interface CinematicEvent
tpf
- time per frame.protected abstract void onUpdate(float tpf)
tpf
- time per framepublic void stop()
stop
in interface CinematicEvent
protected abstract void onStop()
public void pause()
pause
in interface CinematicEvent
public abstract void onPause()
public float getDuration()
getDuration
in interface CinematicEvent
public void setSpeed(float speed)
setSpeed
in interface CinematicEvent
speed
- the desired speedup factor (default=1)public float getSpeed()
getSpeed
in interface CinematicEvent
public PlayState getPlayState()
getPlayState
in interface CinematicEvent
public float getInitialDuration()
getInitialDuration
in interface CinematicEvent
public void setInitialDuration(float initialDuration)
setInitialDuration
in interface CinematicEvent
initialDuration
- the desired duration (in de-scaled seconds)public LoopMode getLoopMode()
getLoopMode
in interface CinematicEvent
LoopMode
public void setLoopMode(LoopMode loopMode)
setLoopMode
in interface CinematicEvent
loopMode
- the desired mode (default=DontLoop)LoopMode
public void write(JmeExporter ex) throws java.io.IOException
public void read(JmeImporter im) throws java.io.IOException
public void initEvent(Application app, Cinematic cinematic)
initEvent
in interface CinematicEvent
app
- ignoredcinematic
- ignoredpublic void addListener(CinematicEventListener listener)
listener
- CinematicEventListenerpublic void removeListener(CinematicEventListener listener)
listener
- CinematicEventListenerpublic void setTime(float time)
setTime
in interface CinematicEvent
time
- the time to fast forward to.public float getTime()
getTime
in interface CinematicEvent
public void dispose()
CinematicEvent
dispose
in interface CinematicEvent