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

public abstract class AbstractCinematicEvent extends Object implements CinematicEvent
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
    Modifier and Type
    Field
    Description
    protected float
     
    The list of listeners.
    protected LoopMode
     
    protected PlayState
     
    protected boolean
     
    protected float
     
    protected float
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    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.
    Construct a cinematic event with the given loopMode.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a CinematicEventListener to this event.
    void
    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
    Returns the speed of the animation.
    float
    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
    Implement this method with code that you want to execute when the event is paused.
    protected abstract void
    Implement this method with code that you want to execute when the event is started.
    protected abstract void
    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 this event.
    void
    Play this event.
    void
    Used for serialization only.
    void
    Removes a CinematicEventListener from this event.
    void
    setInitialDuration(float initialDuration)
    Sets the duration of the animation at speed = 1 in seconds.
    void
    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
    Stops the animation.
    void
    Used for serialization only.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • playState

      protected PlayState playState
    • loopMode

      protected LoopMode loopMode
    • initialDuration

      protected float initialDuration
    • speed

      protected float speed
    • time

      protected float time
    • resuming

      protected boolean resuming
    • listeners

      protected List<CinematicEventListener> 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

      public AbstractCinematicEvent(LoopMode loopMode)
      Construct a cinematic event with the given loopMode.
      Parameters:
      loopMode - the desired mode (Loop/DontLoop/Cycle)
    • AbstractCinematicEvent

      public AbstractCinematicEvent(float initialDuration, LoopMode loopMode)
      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 interface CinematicEvent
    • play

      public void play()
      Play this event.
      Specified by:
      play in interface CinematicEvent
    • 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 interface CinematicEvent
      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 interface CinematicEvent
    • 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 interface CinematicEvent
    • 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 interface CinematicEvent
      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 interface CinematicEvent
      Parameters:
      speed - the desired speedup factor (default=1)
    • getSpeed

      public float getSpeed()
      Returns the speed of the animation.
      Specified by:
      getSpeed in interface CinematicEvent
      Returns:
      the speed
    • getPlayState

      public PlayState getPlayState()
      Returns the current play state of the animation (playing or paused or stopped).
      Specified by:
      getPlayState in interface CinematicEvent
      Returns:
      the enum value
    • getInitialDuration

      public float getInitialDuration()
      Returns the initial duration of the animation at speed = 1 in seconds.
      Specified by:
      getInitialDuration in interface CinematicEvent
      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 interface CinematicEvent
      Parameters:
      initialDuration - the desired duration (in de-scaled seconds)
    • getLoopMode

      public LoopMode getLoopMode()
      Returns the loopMode of the animation.
      Specified by:
      getLoopMode in interface CinematicEvent
      Returns:
      the enum value
      See Also:
    • setLoopMode

      public void setLoopMode(LoopMode loopMode)
      Sets the loopMode of the animation.
      Specified by:
      setLoopMode in interface CinematicEvent
      Parameters:
      loopMode - the desired mode (default=DontLoop)
      See Also:
    • write

      public void write(JmeExporter ex) throws IOException
      Used for serialization only.
      Specified by:
      write in interface Savable
      Parameters:
      ex - exporter
      Throws:
      IOException - from the exporter
    • read

      public void read(JmeImporter im) throws IOException
      Used for serialization only.
      Specified by:
      read in interface Savable
      Parameters:
      im - importer
      Throws:
      IOException - from the importer
    • initEvent

      public void initEvent(Application app, Cinematic cinematic)
      Initialize this event (called internally only).
      Specified by:
      initEvent in interface CinematicEvent
      Parameters:
      app - ignored
      cinematic - ignored
    • addListener

      public void addListener(CinematicEventListener listener)
      Adds a CinematicEventListener to this event.
      Parameters:
      listener - CinematicEventListener
    • removeListener

      public void removeListener(CinematicEventListener listener)
      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 interface CinematicEvent
      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 interface CinematicEvent
      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 interface CinematicEvent