Package com.jme3.cinematic.events
Class AbstractCinematicEvent
java.lang.Object
com.jme3.cinematic.events.AbstractCinematicEvent
- All Implemented Interfaces:
CinematicEvent
,Savable
- Direct Known Subclasses:
AnimationEvent
,AnimEvent
,CameraEvent
,Cinematic
,GuiEvent
,GuiTrack
,MotionEvent
,SoundEvent
This call contains the basic behavior of a cinematic event.
Every cinematic event must extend this class.
A cinematic event must be given an initial duration in seconds
(duration of the event at speed = 1). Default is 10 sec.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstruct 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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(CinematicEventListener listener) Adds 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
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
Returns the actual duration of the animation (initialDuration/speed)float
Returns the initial duration of the animation at speed = 1 in seconds.Returns the loopMode of the animation.Returns the current play state 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) Removes 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-forwards the event to the given timestamp.void
stop()
Stops the animation.void
write
(JmeExporter ex) Used for serialization only.
-
Field Details
-
playState
-
loopMode
-
initialDuration
protected float initialDuration -
speed
protected float speed -
time
protected float time -
resuming
protected boolean resuming -
listeners
The list of listeners.
-
-
Constructor Details
-
AbstractCinematicEvent
public AbstractCinematicEvent()Construct a cinematic event (empty constructor). -
AbstractCinematicEvent
public AbstractCinematicEvent(float initialDuration) Construct a cinematic event with the given initial duration.- Parameters:
initialDuration
- the desired duration (in seconds, default=10)
-
AbstractCinematicEvent
Construct a cinematic event with the given loopMode.- Parameters:
loopMode
- the desired mode (Loop/DontLoop/Cycle)
-
AbstractCinematicEvent
Construct a cinematic event with the given loopMode and the given initialDuration.- Parameters:
initialDuration
- the duration of the event at speed = 1.loopMode
- the loop mode of the event.
-
-
Method Details
-
forceStop
public 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. By default, this method just calls regular stop().- Specified by:
forceStop
in interfaceCinematicEvent
-
play
public void play()Play this event.- Specified by:
play
in interfaceCinematicEvent
-
onPlay
protected abstract void onPlay()Implement this method with code that you want to execute when the event is started. -
internalUpdate
public void internalUpdate(float tpf) Used internally only.- Specified by:
internalUpdate
in interfaceCinematicEvent
- Parameters:
tpf
- time per frame.
-
onUpdate
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).- Parameters:
tpf
- time per frame
-
stop
public void stop()Stops the animation. Next time when play() is called, the animation starts from the beginning.- Specified by:
stop
in interfaceCinematicEvent
-
onStop
protected abstract void onStop()Implement this method with code that you want to execute when the event is stopped. -
pause
public void pause()Pause this event. Next time when play() is called, the animation restarts from here.- Specified by:
pause
in interfaceCinematicEvent
-
onPause
public abstract void onPause()Implement this method with code that you want to execute when the event is paused. -
getDuration
public float getDuration()Returns the actual duration of the animation (initialDuration/speed)- Specified by:
getDuration
in interfaceCinematicEvent
- Returns:
- the duration (in seconds)
-
setSpeed
public void setSpeed(float speed) Sets the speed of the animation. At speed = 1, the animation will last initialDuration seconds, At speed = 2, the animation will last initialDuration/2...- Specified by:
setSpeed
in interfaceCinematicEvent
- Parameters:
speed
- the desired speedup factor (default=1)
-
getSpeed
public float getSpeed()Returns the speed of the animation.- Specified by:
getSpeed
in interfaceCinematicEvent
- Returns:
- the speed
-
getPlayState
Returns the current play state of the animation (playing or paused or stopped).- Specified by:
getPlayState
in interfaceCinematicEvent
- Returns:
- the enum value
-
getInitialDuration
public float getInitialDuration()Returns the initial duration of the animation at speed = 1 in seconds.- Specified by:
getInitialDuration
in interfaceCinematicEvent
- Returns:
- the duration in seconds
-
setInitialDuration
public void setInitialDuration(float initialDuration) Sets the duration of the animation at speed = 1 in seconds.- Specified by:
setInitialDuration
in interfaceCinematicEvent
- Parameters:
initialDuration
- the desired duration (in de-scaled seconds)
-
getLoopMode
Returns the loopMode of the animation.- Specified by:
getLoopMode
in interfaceCinematicEvent
- Returns:
- the enum value
- See Also:
-
setLoopMode
Sets the loopMode of the animation.- Specified by:
setLoopMode
in interfaceCinematicEvent
- Parameters:
loopMode
- the desired mode (default=DontLoop)- See Also:
-
write
Used for serialization only.- Specified by:
write
in interfaceSavable
- Parameters:
ex
- exporter- Throws:
IOException
- from the exporter
-
read
Used for serialization only.- Specified by:
read
in interfaceSavable
- Parameters:
im
- importer- Throws:
IOException
- from the importer
-
initEvent
Initialize this event (called internally only).- Specified by:
initEvent
in interfaceCinematicEvent
- Parameters:
app
- ignoredcinematic
- ignored
-
addListener
Adds a CinematicEventListener to this event.- Parameters:
listener
- CinematicEventListener
-
removeListener
Removes a CinematicEventListener from this event.- Parameters:
listener
- CinematicEventListener
-
setTime
public void setTime(float time) Fast-forwards the event to the given timestamp. Time=0 is the start of the event.- Specified by:
setTime
in interfaceCinematicEvent
- Parameters:
time
- the time to fast-forward to.
-
getTime
public float getTime()Return the current timestamp of the event. Time=0 is the start of the event.- Specified by:
getTime
in interfaceCinematicEvent
- Returns:
- the time
-
dispose
public void dispose()Description copied from interface:CinematicEvent
method called when an event is removed from a cinematic this method should remove any reference to any external objects.- Specified by:
dispose
in interfaceCinematicEvent
-