Skip to content

FxPlayback ​

This module contains functions for controlling the playback of scenes. The first frame is numbered 1.

Load ​

lua
FxPlayback = require "FxPlayback";

Functions ​

FunctionDescription
GetDuration ()Returns the animation duration.
GetFPS ()Returns the number of frames per second.
GetFrame ()Returns the current frame.
GetLoop ()Returns whether playback is looped.
GetPlaying ()Returns whether the scene is currently playing.
GetRange ()Returns the playback range.
GetSpeed ()Returns the playback speed factor.
Play ()Plays the playback range.
SetFrame (Value)Sets the current frame.
SetLoop (Value)Sets playback looping.
SetRange (FrameStart, FrameEnd)Sets the playback range.
SetSpeed (Value)Sets the playback speed factor.
Stop ()Stops playback.

GetDuration () ​

This function returns the duration of the animation.

Returns ​

The duration of the animation

Since ​

Version 1.0

Example ​

lua
duration = FxPlayback.GetDuration();

GetFPS () ​

This function returns the number of frames per second used for playback.

Returns ​

The number of frames per second

Since ​

Version 1.0

Example ​

lua
fps = FxPlayback.GetFPS();

GetFrame () ​

This function returns the current frame.

Returns ​

The current frame

Since ​

Version 1.0

Example ​

lua
frame = FxPlayback.GetFrame();

GetLoop () ​

This function returns whether playback is looped.

Returns ​

The loop state

Since ​

Version 1.0

Example ​

lua
looping = FxPlayback.GetLoop();

GetPlaying () ​

This function returns whether the scene is currently playing.

Returns ​

Playing state

Since ​

Version 1.0

Example ​

lua
playing = FxPlayback.GetPlaying();

GetRange () ​

This function returns the playback range.

Returns ​

Playback range

Since ​

Version 1.0

Example ​

lua
frameStart frameEnd = FxPlayback.GetRange();

GetSpeed () ​

This function returns the speed factor applied to the number of frames per second.

Returns ​

Playback speed factor

Since ​

Version 1.0

Example ​

lua
speedfactor = FxPlayback.GetSpeed();

Play () ​

This function sets the current frame to the beginning of the playback range and starts playback. Playback stops at the end of the playback range, unless looping is enabled.

INFO

This function is disabled when running Foxel in command line mode.

Errors ​

Possible errors include FX_REQUIRED_ASSET_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
FxPlayback.Play();

SetFrame (Value) ​

This function sets the current frame. The value is clamped to the range [1..duration].

Parameters ​

  • Value: The new frame number

Errors ​

Possible errors include FX_REQUIRED_ASSET_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
FxPlayback.SetFrame(10);

SetLoop (Value) ​

This function sets whether playback is looped. If enabled, the playback range will be looped until manually stopped.

Parameters ​

  • Value: The new loop state

Errors ​

Possible errors include FX_REQUIRED_ASSET_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
FxPlayback.SetLoop(true);

SetRange (FrameStart, FrameEnd) ​

This function sets the playback range, which must be within [1..duration].

Parameters ​

  • FrameStart: The first frame of the playback range
  • FrameEnd: The last frame of playback range

Errors ​

Possible errors include FX_REQUIRED_ASSET_UNAVAILABLE, FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
FxPlayback.SetRange(5, 20);

SetSpeed (Value) ​

This function sets the playback speed factor that is applied to the number of frames per second.

Parameters ​

  • Value: The new playback speed factor

Errors ​

Possible errors include FX_REQUIRED_ASSET_UNAVAILABLE, FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
-- set playback with half speed
FxPlayback.SetSpeed(0.5);

Stop () ​

This function stops playback.

Errors ​

Possible errors include FX_REQUIRED_ASSET_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
FxPlayback.Stop();