Skip to content

Latest commit

 

History

History
262 lines (181 loc) · 7.06 KB

File metadata and controls

262 lines (181 loc) · 7.06 KB

panthera API

at /panthera/panthera.lua

Functions

Fields

set_logger


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

create_go


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

create_gui


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

create


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 resources
    • adapter (panthera.adapter): An adapter object that specifies how Panthera Runtime interacts with Engine
    • get_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

clone_state


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

play


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 by create_go or create_gui
    • animation_id (string): The ID of the animation to play
    • [options] ((panthera.options)?): Options for the animation playback
  • Returns:

    • `` (nil):

set_time


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 by create_go or create_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

get_time


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

stop


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

get_duration


panthera.get_duration(animation_state, animation_id)

Retrieve the total duration of a specific animation.

  • Parameters:

    • animation_state (panthera.animation): The animation state object
    • animation_id (string): The ID of the animation whose duration you want to retrieve
  • Returns:

    • seconds (number): The total duration of the animation in seconds

is_playing


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

get_latest_animation_id


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

get_animations


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

reload_animation


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

Fields

  • SPEED (number): Default speed of all animations

  • OPTIONS_LOOP (table): Set of predefined options

  • OPTIONS_SKIP_INIT (table)

  • OPTIONS_SKIP_INIT_LOOP (table)