at /panthera/panthera.lua
- set_logger
- create_go
- create_gui
- create
- clone_state
- play
- set_time
- get_time
- stop
- get_duration
- is_playing
- get_latest_animation_id
- get_animations
- reload_animation
panthera.set_logger([logger_instance])Customize the logging mechanism used by Panthera Runtime. You can use Defold Log library or provide a custom logger.
- Parameters:
[logger_instance]((table|panthera.logger)?): A logger object that follows the specified logging interface. Pass nil to use empty logger
panthera.create_go(animation_or_path, [collection_name], [objects])Load and create a game object animation state from a Lua table or JSON file.
-
Parameters:
animation_or_path(string|table): Lua table with animation data or path to JSON animation file in custom resources[collection_name](string?): Collection name to load nodes from. Pass nil if no collection is used[objects](table<string|hash, string|hash>?): Table with game objects from collectionfactory. Pass nil if no objects are used
-
Returns:
animation(panthera.animation): New animation state object
panthera.create_gui(animation_or_path, [template], [nodes])Load and create a GUI animation state from a Lua table or JSON file.
-
Parameters:
animation_or_path(string|table): Lua table with animation data or path to JSON animation file in custom resources[template](string?): The GUI template ID to load nodes from. Pass nil if no template is used[nodes](table<string|hash, node>?): Table with nodes from gui.clone_tree() function. Pass nil if no nodes are used
-
Returns:
animation(panthera.animation): New animation state object
panthera.create(animation_or_path, adapter, get_node)Load an animation from a Lua table or JSON file and create an animation state using a specified adapter.
-
Parameters:
animation_or_path(string|table): Lua table with animation data or path to JSON animation file in custom resourcesadapter(panthera.adapter): An adapter object that specifies how Panthera Runtime interacts with Engineget_node(fun(node_id: string):node): Function to get node by node_id. A custom function to resolve nodes by their ID
-
Returns:
animation(panthera.animation): New animation state object
panthera.clone_state(animation_state)Clone an existing animation state object, enabling multiple instances of the same animation to play simultaneously or independently.
-
Parameters:
animation_state(panthera.animation): The animation state object to clone
-
Returns:
animation(panthera.animation): New animation state object that is a copy of the original
panthera.play(animation_state, animation_id, [options])Play an animation with specified ID and options.
-
Parameters:
animation_state(panthera.animation): The animation state object returned bycreate_goorcreate_guianimation_id(string): The ID of the animation to play[options]((panthera.options)?): Options for the animation playback
-
Returns:
- `` (nil):
panthera.set_time(animation_state, animation_id, time, [event_callback])Set the current time of an animation. This function stops any currently playing animation.
-
Parameters:
animation_state(panthera.animation): The animation state object returned bycreate_goorcreate_gui.animation_id(string): The ID of the animation to modify.time(number): The target time in seconds to which the animation should be set.[event_callback](fun(event_id: string, node: node|nil, string_value: string, number_value: number)|nil):
-
Returns:
result(boolean): True if animation state was set successfully, false if animation can't be set
panthera.get_time(animation_state)Retrieve the current playback time in seconds of an animation. If the animation is not playing, the function returns 0.
-
Parameters:
animation_state(panthera.animation): The animation state object
-
Returns:
seconds(number): Current animation time in seconds
panthera.stop(animation_state)Stop a currently playing animation. The animation will be stopped at current time.
-
Parameters:
animation_state(panthera.animation): The animation state object to stop
-
Returns:
is_stopped(boolean): True if animation was stopped, false if animation is not playing
panthera.get_duration(animation_state, animation_id)Retrieve the total duration of a specific animation.
-
Parameters:
animation_state(panthera.animation): The animation state objectanimation_id(string): The ID of the animation whose duration you want to retrieve
-
Returns:
seconds(number): The total duration of the animation in seconds
panthera.is_playing(animation_state)Check if an animation is currently playing.
-
Parameters:
animation_state(panthera.animation): The animation state object
-
Returns:
is_playing(boolean): True if the animation is currently playing, false otherwise
panthera.get_latest_animation_id(animation_state)Get the ID of the last animation that was started.
-
Parameters:
animation_state(panthera.animation): The animation state object
-
Returns:
animation_id(string?): Animation ID or nil if no animation was started
panthera.get_animations(animation_state)Return a list of animation IDs from the created animation state.
-
Parameters:
animation_state(panthera.animation): The animation state object
-
Returns:
animation_ids(string[]): Array of animation IDs available in the animation state
panthera.reload_animation([animation_path])Reload animations from JSON files, useful for development and debugging. The animations loaded from Lua tables will not be reloaded. Animation will be reloaded only at desktop.
- Parameters:
[animation_path](string?): Specific animation to reload. If omitted, all loaded animations are reloaded
- SPEED (number): Default speed of all animations
- OPTIONS_LOOP (table): Set of predefined options
- OPTIONS_SKIP_INIT (table)
- OPTIONS_SKIP_INIT_LOOP (table)