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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstruct 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 TypeMethodDescriptionvoidaddListener(CinematicEventListener listener) Adds a CinematicEventListener to this event.voiddispose()method called when an event is removed from a cinematic this method should remove any reference to any external objects.voidImplement 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.floatReturns the actual duration of the animation (initialDuration/speed)floatReturns 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).floatgetSpeed()Returns the speed of the animation.floatgetTime()Return the current timestamp of the event.voidinitEvent(Application app, Cinematic cinematic) Initialize this event (called internally only).voidinternalUpdate(float tpf) Used internally only.abstract voidonPause()Implement this method with code that you want to execute when the event is paused.protected abstract voidonPlay()Implement this method with code that you want to execute when the event is started.protected abstract voidonStop()Implement this method with code that you want to execute when the event is stopped.protected abstract voidonUpdate(float tpf) Implement this method with the code that you want to execute on update (only called when the event is playing).voidpause()Pause this event.voidplay()Play this event.voidread(JmeImporter im) Used for serialization only.voidremoveListener(CinematicEventListener listener) Removes a CinematicEventListener from this event.voidsetInitialDuration(float initialDuration) Sets the duration of the animation at speed = 1 in seconds.voidsetLoopMode(LoopMode loopMode) Sets the loopMode of the animation.voidsetSpeed(float speed) Sets the speed of the animation.voidsetTime(float time) Fast-forwards the event to the given timestamp.voidstop()Stops the animation.voidwrite(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:
forceStopin interfaceCinematicEvent
-
play
public void play()Play this event.- Specified by:
playin 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:
internalUpdatein 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:
stopin 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:
pausein 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:
getDurationin 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:
setSpeedin interfaceCinematicEvent- Parameters:
speed- the desired speedup factor (default=1)
-
getSpeed
public float getSpeed()Returns the speed of the animation.- Specified by:
getSpeedin interfaceCinematicEvent- Returns:
- the speed
-
getPlayState
Returns the current play state of the animation (playing or paused or stopped).- Specified by:
getPlayStatein interfaceCinematicEvent- Returns:
- the enum value
-
getInitialDuration
public float getInitialDuration()Returns the initial duration of the animation at speed = 1 in seconds.- Specified by:
getInitialDurationin 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:
setInitialDurationin interfaceCinematicEvent- Parameters:
initialDuration- the desired duration (in de-scaled seconds)
-
getLoopMode
Returns the loopMode of the animation.- Specified by:
getLoopModein interfaceCinematicEvent- Returns:
- the enum value
- See Also:
-
setLoopMode
Sets the loopMode of the animation.- Specified by:
setLoopModein interfaceCinematicEvent- Parameters:
loopMode- the desired mode (default=DontLoop)- See Also:
-
write
Used for serialization only.- Specified by:
writein interfaceSavable- Parameters:
ex- exporter- Throws:
IOException- from the exporter
-
read
Used for serialization only.- Specified by:
readin interfaceSavable- Parameters:
im- importer- Throws:
IOException- from the importer
-
initEvent
Initialize this event (called internally only).- Specified by:
initEventin 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:
setTimein 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:
getTimein interfaceCinematicEvent- Returns:
- the time
-
dispose
public void dispose()Description copied from interface:CinematicEventmethod called when an event is removed from a cinematic this method should remove any reference to any external objects.- Specified by:
disposein interfaceCinematicEvent
-