### Basic GUI Animation Setup Source: https://github.com/insality/panthera/blob/main/README.md Initialize and play a default animation for a GUI node using Panthera Runtime. Ensure the animation Lua file is correctly path-ed. ```lua local panthera = require("panthera.panthera") local animation = require("gui.my_gui_panthera") -- Path to Lua animation file function init(self) sself.animation = panthera.create_gui(animation) panthera.play(self.animation, "default", { is_loop = true }) end ``` -------------------------------- ### Basic Collections Animation Setup Source: https://github.com/insality/panthera/blob/main/README.md Initialize and play a default animation for a collection scene using Panthera Runtime. Ensure the animation Lua file is correctly path-ed. ```lua local panthera = require("panthera.panthera") local animation = require("entities.my_entity_panthera") -- Path to Lua animation file function init(self) sself.animation = panthera.create_go(animation) panthera.play(self.animation, "default", { is_loop = true }) end ``` -------------------------------- ### Play Animation in Defold GUI Source: https://github.com/insality/panthera/blob/main/docs_editor/getting_started.md Example of how to create and play a Panthera animation within a Defold GUI script. Requires the 'panthera' and animation modules. ```lua local panthera = require("panthera.panthera") local animation = require("gui.my_gui_panthera") function init(self) self.animation = panthera.create_gui(animation) panthera.play(self.animation, "appear", { is_loop = false }) end ``` -------------------------------- ### Play Animation in Defold Collection/GO Source: https://github.com/insality/panthera/blob/main/docs_editor/getting_started.md Example of how to create and play a Panthera animation for a Defold Collection or Game Object. Requires the 'panthera' and animation modules. ```lua local panthera = require("panthera.panthera") local animation = require("entities.my_entity_panthera") function init(self) self.animation = panthera.create_go(animation) panthera.play(self.animation, "appear", { is_loop = true }) end ``` -------------------------------- ### panthera.create_go Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Loads and creates a game object (GO) animation state from a JSON file or Lua table. It allows specifying a collection name and objects for more complex setups. ```APIDOC ## panthera.create_go ### Description Loads and creates a game object (GO) animation state from a JSON file or Lua table. Supports loading from paths or Lua tables, with optional collection names and object mappings. ### Method Signature ```lua panthera.create_go(animation_or_path, [collection_name], [objects]) ``` ### Parameters - `animation_or_path` (string | table): The path to the animation JSON file or a table with animation data. Example: `/animations/my_animation.json`. - `collection_name` (string, optional): The name of the collection to load objects from. Pass `nil` if no collection is used. - `objects` (table, optional): Table with object ids from collectionfactory.create() function. Pass `nil` if objects are not created. ### Returns - An animation state object or `nil` if the animation cannot be loaded. ### Usage Example ```lua local PATH = "/animations/my_animation.json" -- Create over objects on current scene local go_animation = panthera.create_go(PATH) -- Create over collection on current scene local go_animation = panthera.create_go(PATH, "collection_name") -- Create over Game Object from spawned factory -- You should create a table with mapping object to created instance. -- Instead "/pantera" use object id from animation local object = factory.create("#factory") local go_animation = panthera.create_go(PATH, nil, { [hash("/panthera")] = object }) -- Create over objects from spawned collectionfactory local objects = collectionfactory.create("#collectionfactory") local go_animation = panthera.create_go(PATH, nil, objects) -- Create over objects from collectionfactory inside spawned collection local objects = collectionfactory.create("#collectionfactory") local go_animation = panthera.create_go(PATH, "collection_name", objects) ``` ```lua -- Using Lua table with animation data local animation_data = require("animations.my_animation_data") local go_animation = panthera.create_go(animation_data) ``` ``` -------------------------------- ### panthera.play Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Plays an animation. This function starts or resumes the playback of an animation. ```APIDOC ## panthera.play ### Description Plays an animation. This function starts or resumes the playback of an animation. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua panthera.play(animation_object) ``` ### Response None explicitly documented. ``` -------------------------------- ### panthera.get_time Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Gets the current playback time of an animation. ```APIDOC ## panthera.get_time ### Description Gets the current playback time of an animation. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua local current_time = panthera.get_time(animation_object) ``` ### Response Returns the current playback time in seconds. ``` -------------------------------- ### Get Latest Animation ID Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Retrieves the ID of the most recently started animation. Returns nil if no animation has been started yet. ```lua panthera.get_latest_animation_id(animation_state) ``` -------------------------------- ### Get Latest Animation ID Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Retrieve the ID of the last animation that was started. ```lua local animation_id = panthera.get_latest_animation_id(animation_state) ``` -------------------------------- ### get_duration Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Get the duration of an animation in seconds. ```APIDOC ## get_duration ### Description Get the duration of an animation in seconds. ### Method `panthera.get_duration` ### Parameters #### Arguments - `animation_state` (panthera.animation) - The animation state object ### Returns - `seconds` (number) - Animation duration in seconds ``` -------------------------------- ### panthera.get_duration Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Gets the total duration of an animation. ```APIDOC ## panthera.get_duration ### Description Gets the total duration of an animation. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua local duration = panthera.get_duration(animation_object) ``` ### Response Returns the total duration of the animation in seconds. ``` -------------------------------- ### get_latest_animation_id Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Gets the ID of the last animation that was started. ```APIDOC ## get_latest_animation_id ### Description Get the ID of the last animation that was started. ### Method ```lua panthera.get_latest_animation_id(animation_state) ``` ### Parameters #### Path Parameters - **animation_state** (panthera.animation) - Required - The animation state object ### Returns #### Success Response - **animation_id** (string?) - Animation ID or nil if no animation was started ``` -------------------------------- ### get_animations Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Get a list of all available animation IDs within the animation state. ```APIDOC ## get_animations ### Description Get a list of all available animation IDs within the animation state. ### Method `panthera.get_animations` ### Parameters #### Arguments - `animation_state` (panthera.animation) - The animation state object ### Returns - `animation_ids` (table) - A table containing all animation IDs ``` -------------------------------- ### Get All Animation IDs Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Returns a list of all animation IDs available within the animation state. Useful for iterating or managing multiple animations. ```lua panthera.get_animations(animation_state) ``` -------------------------------- ### get_latest_animation_id Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Get the ID of the latest animation that was played. ```APIDOC ## get_latest_animation_id ### Description Get the ID of the latest animation that was played. ### Method `panthera.get_latest_animation_id` ### Parameters #### Arguments - `animation_state` (panthera.animation) - The animation state object ### Returns - `animation_id` (string) - The ID of the latest animation played ``` -------------------------------- ### panthera.get_latest_animation_id Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Gets the ID of the latest animation that was played or processed. ```APIDOC ## panthera.get_latest_animation_id ### Description Gets the ID of the latest animation that was played or processed. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua local latest_id = panthera.get_latest_animation_id() ``` ### Response Returns the ID of the latest animation. ``` -------------------------------- ### Get Animation Playback Time Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Retrieve the current playback time in seconds of an animation. If the animation is not currently playing, the function returns 0. ```lua panthera.get_time(animation_state) ``` -------------------------------- ### Get Animation Duration Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Retrieves the total duration of a specific animation by its ID. Useful for timing-related logic. ```lua panthera.get_duration(animation_state, animation_id) ``` -------------------------------- ### Create GUI Animation from Path Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Loads a GUI animation state from a JSON file path. Ensure the animation file is placed in the custom resources folder. ```lua local PATH = "/animations/my_gui_animation.json" -- Create over GUI on current scene local gui_animation = panthera.create_gui(PATH) ``` ```lua -- Create over GUI template on current scene local gui_animation = panthera.create_gui(PATH, "template_name") ``` ```lua -- Create over cloned GUI nodes local nodes = gui.clone_tree(gui.get_node("root")) local gui_animation = panthera.create_gui(PATH, nil, nodes) ``` ```lua -- Create over cloned GUI template local nodes = gui.clone_tree(gui.get_node("template_name/root")) local gui_animation = panthera.create_gui(PATH, "template_name", nodes) ``` -------------------------------- ### create Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Load an animation from a Lua table or JSON file and create an animation state using a specified adapter. ```APIDOC ## create ### Description Load an animation from a Lua table or JSON file and create an animation state using a specified adapter. ### Method `panthera.create` ### Parameters #### Arguments - `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 ``` -------------------------------- ### create_gui Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Load and create a GUI animation state from a Lua table or JSON file. ```APIDOC ## create_gui ### Description Load and create a GUI animation state from a Lua table or JSON file. ### Method `panthera.create_gui` ### Parameters #### Arguments - `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?) - Table with nodes from gui.clone_tree() function. Pass nil if no nodes are used ### Returns - `animation` (panthera.animation) - New animation state object ``` -------------------------------- ### create_go Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Load and create a game object animation state from a Lua table or JSON file. ```APIDOC ## create_go ### Description Load and create a game object animation state from a Lua table or JSON file. ### Method `panthera.create_go` ### Parameters #### Arguments - `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?) - Table with game objects from collectionfactory. Pass nil if no objects are used ### Returns - `animation` (panthera.animation) - New animation state object ``` -------------------------------- ### Defold GUI Adapter Implementation Source: https://github.com/insality/panthera/blob/main/docs/panthera_adapter.md This Lua code defines a basic adapter for Defold GUI nodes. It includes functions for easing, setting node properties, tweening animations, stopping tweens, and triggering non-tween animation keys. Implement specific logic for `trigger_animation_key` as needed. ```lua local M = { get_easing = function(easing_name) -- Returns a Defold easing type. This example always returns LINEAR easing. -- You might want to map Panthera easing names to Defold's easing constants. return gui.EASING_LINEAR end, set_node_property = function(node, property_id, value) -- Sets a property of a node to a specified value. gui.set(node, property_id, value) end, tween_animation_key = function(node, property_id, easing, duration, end_value) -- Applies a tween to a node property based on Panthera animation key data. gui.animate(node, property_id, end_value, easing, duration) end, stop_tween = function(node, property_id) -- Stops any ongoing tween on a node property. gui.cancel_animation(node, property_id) end, trigger_animation_key = function(node, property_id, value) -- Intended for triggering non-tween animation keys, such as sound or event triggers. -- This example logs a message, but you should implement specific logic as needed. print("Triggering animation key for non-tween values. Node: ", node_id, " Property: ", property_id, " Value: ", value) end, } ``` -------------------------------- ### Import Panthera Runtime Module Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Import the Panthera Runtime module to begin using its functionalities in your Defold project. ```lua local panthera = require("panthera.panthera") ``` -------------------------------- ### Create Animation State with GO Adapter Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Creates an animation state object for a game object using the default GO adapter. Requires the path to the animation JSON file. ```lua local go_animation_state = panthera.create("/animations/player_animation.json", adapter_go) ``` -------------------------------- ### Create Game Object Animation from Path Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Loads a Game Object animation state from a JSON file path. Ensure the animation file is placed in the custom resources folder. ```lua local PATH = "/animations/my_animation.json" -- Create over objects on current scene local go_animation = panthera.create_go(PATH) ``` ```lua -- Create over collection on current scene local go_animation = panthera.create_go(PATH, "collection_name") ``` ```lua -- Create over Game Object from spawned factory -- You should create a table with mapping object to created instance. -- Instead "/pantera" use object id from animation local object = factory.create("#factory") local go_animation = panthera.create_go(PATH, nil, { [hash("/panthera")] = object }) ``` ```lua -- Create over objects from spawned collectionfactory local objects = collectionfactory.create("#collectionfactory") local go_animation = panthera.create_go(PATH, nil, objects) ``` ```lua -- Create over objects from collectionfactory inside spawned collection local objects = collectionfactory.create("#collectionfactory") local go_animation = panthera.create_go(PATH, "collection_name", objects) ``` -------------------------------- ### Create Animation State with GUI Adapter Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Creates an animation state object for GUI elements using the GUI adapter. Requires the path to the animation JSON file. ```lua local adapter_gui = require("panthera.adapters.adapter_gui") local gui_animation_state = panthera.create("/animations/gui_animation.json", adapter_gui) ``` -------------------------------- ### panthera.create_gui Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Loads and creates a GUI animation state from a JSON file or Lua table. It supports loading from paths or Lua tables, with optional GUI template IDs and cloned nodes. ```APIDOC ## panthera.create_gui ### Description Loads and creates a GUI animation state from a JSON file or Lua table. Supports loading from paths or Lua tables, with optional GUI template IDs and cloned nodes. ### Method Signature ```lua panthera.create_gui(animation_or_path, [template], [nodes]) ``` ### Parameters - `animation_or_path` (string | table): The path to the animation JSON file or a table with animation data. Example: `/animations/my_gui_animation.json`. - `template` (string, optional): The GUI template id to load nodes from. Pass nil if no template is used. - `nodes` (table, optional): Table with nodes from `gui.clone_tree()` function. Pass nil if nodes are not cloned. ### Returns - An animation state object or `nil` if the animation cannot be loaded. ### Usage Example ```lua local PATH = "/animations/my_gui_animation.json" -- Create over GUI on current scene local gui_animation = panthera.create_gui(PATH) -- Create over GUI template on current scene local gui_animation = panthera.create_gui(PATH, "template_name") -- Create over cloned GUI nodes local nodes = gui.clone_tree(gui.get_node("root")) local gui_animation = panthera.create_gui(PATH, nil, nodes) -- Create over cloned GUI template local nodes = gui.clone_tree(gui.get_node("template_name/root")) local gui_animation = panthera.create_gui(PATH, "template_name", nodes) ``` ```lua -- Using Lua table with animation data local animation_data = require("animations.my_animation_data") local gui_animation = panthera.create_gui(animation_data) ``` ``` -------------------------------- ### panthera.create_go Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Creates a game object for animation playback. This function is used to initialize an animation in a game object context. ```APIDOC ## panthera.create_go ### Description Creates a game object for animation playback. This function is used to initialize an animation in a game object context. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua local go_object = panthera.create_go() ``` ### Response Returns a game object that can be used for animation control. ``` -------------------------------- ### Panthera Runtime API Quick Reference Source: https://github.com/insality/panthera/blob/main/README.md A summary of the core functions and constants available in the Panthera Runtime API for animation state management and utility operations. ```lua local panthera = require("panthera.panthera") -- Create animation state panthera.create_go(animation_or_path, [collection_name], [objects]) panthera.create_gui(animation_or_path, [template], [nodes]) panthera.create(animation_or_path, adapter, get_node) panthera.clone_state(animation_state) panthera.play(animation_state, animation_id, [options]) panthera.set_time(animation_state, animation_id, time, [event_callback]) panthera.get_time(animation_state) panthera.stop(animation_state) panthera.get_duration(animation_state, animation_id) panthera.is_playing(animation_state) panthera.get_latest_animation_id(animation_state) panthera.get_animations(animation_state) -- Utils panthera.set_logger([logger_instance]) panthera.reload_animation([animation_path]) panthera.SPEED panthera.OPTIONS_LOOP panthera.OPTIONS_SKIP_INIT panthera.OPTIONS_SKIP_INIT_LOOP ``` -------------------------------- ### panthera.create_gui Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Creates a GUI object for animation playback. This function is used to initialize an animation in a GUI context. ```APIDOC ## panthera.create_gui ### Description Creates a GUI object for animation playback. This function is used to initialize an animation in a GUI context. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua local gui_object = panthera.create_gui() ``` ### Response Returns a GUI object that can be used for animation control. ``` -------------------------------- ### Creating Panthera Animation with Custom Adapter Source: https://github.com/insality/panthera/blob/main/docs/panthera_adapter.md This Lua code demonstrates how to create a Panthera animation using a custom adapter. It requires the path to the animation JSON, the custom adapter module, and a function to retrieve Defold GUI nodes by ID. ```lua local my_custom_adapter = require("path.to.my_custom_adapter") local animation = panthera.create("/path/to/animation.json", my_custom_adapter, function(node_id) return gui.get_node(node_id) end) ``` -------------------------------- ### Add Panthera Runtime Dependency Source: https://github.com/insality/panthera/blob/main/README.md Add the Panthera Runtime library to your game.project file's dependencies. ```text https://github.com/Insality/panthera/archive/refs/tags/runtime.6.zip ``` -------------------------------- ### Create Generic Animation with Custom Adapter Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Loads an animation using a specified adapter and a custom node resolution function. This is a foundational method for creating animations with custom engine interactions. ```lua -- For GO animations local adapter_go = require("panthera.adapters.adapter_go") ``` -------------------------------- ### panthera.create Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md A foundational method to load an animation from a JSON file or Lua table and create an animation state using a specified adapter. It allows for generic animation creation with custom adapters. ```APIDOC ## panthera.create ### Description Loads an animation from a JSON file or Lua table and creates an animation state using a specified adapter. This is a foundational method that `create_go` and `create_gui` build upon, allowing for generic animation creation with custom adapters. ### Method Signature ```lua panthera.create(animation_or_path, adapter, get_node) ``` ### Parameters - `animation_or_path` (string | table): The path to the animation JSON file or a table with animation data. Example: `/animations/my_animation.json`. - `adapter` (object): An adapter object that specifies how Panthera Runtime interacts with Engine. - `get_node` (function): A custom function to resolve nodes by their ID. This function is used by the adapter to retrieve Defold nodes for animation. ### Returns - An animation state object. This object contains the loaded animation data and state necessary for playback. Returns `nil` and an error message if the animation cannot be loaded. ### Usage Example ```lua -- For GO animations local adapter_go = require("panthera.adapters.adapter_go") -- Further usage examples would depend on the specific adapter and get_node function implementation. ``` ``` -------------------------------- ### Customize Animation Playback Options Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Use this to configure loop behavior, playback speed, and callbacks for animation events. Pass an options table to panthera.play. ```lua local options = { is_loop = true, speed = 1.2, callback = function(animation_id) print("Finished animation: " .. animation_id) end, callback_event = function(event_id, node, string_value, number_value) print("Event: " .. event_id) end } panthera.play(animation_state, "animation_id", options) ``` -------------------------------- ### Create Animation with Custom Adapter Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Load an animation from a Lua table or JSON file and create an animation state using a specified adapter and a custom node retrieval function. This offers flexibility in how Panthera interacts with the engine. ```lua panthera.create(animation_or_path, adapter, get_node) ``` -------------------------------- ### panthera.play Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Customizes animation behavior in Panthera Runtime using a table of options passed to `panthera.play`. ```APIDOC ## panthera.play ### Description Customizes animation behavior in Panthera Runtime using a table of options. ### Method `panthera.play(animation_state, animation_id, options)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **`animation_state`**: The animation state object. - **`animation_id`**: The ID of the animation to play. - **`options`** (table): A table of animation playback options. - **`is_loop`** (boolean): Loop the animation (`true`/`false`). Triggers the callback at each loop end if set to `true`. - **`is_skip_init`** (boolean): Start animation from its current state, skipping initial setup (`true`/`false`). - **`speed`** (number): Playback speed multiplier (default `1`). Values >1 increase speed, <1 decrease. - **`callback`** (function): Function called when the animation finishes. Receives `animation_id`. - **`callback_event`** (function): Function triggered by animation events. Receives `event_id`, optional `node`, `string_value`, and `number_value`. ### Request Example ```lua local options = { is_loop = true, speed = 1.2, callback = function(animation_id) print("Finished animation: " .. animation_id) end, callback_event = function(event_id, node, string_value, number_value) print("Event: " .. event_id) end } panthera.play(animation_state, "animation_id", options) ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### play Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Play an animation with specified ID and options. ```APIDOC ## play ### Description Play an animation with specified ID and options. ### Method `panthera.play` ### Parameters #### Arguments - `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 ``` -------------------------------- ### Play Animation with Options Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Plays a specified animation on an animation state object. Supports options like looping and playback speed. ```lua panthera.play(go_animation_state, "walk", { is_loop = true, speed = 1 }) ``` -------------------------------- ### Add Defold Tweener Dependency Source: https://github.com/insality/panthera/blob/main/README.md Add the Defold Tweener library to your game.project file's dependencies. ```text https://github.com/Insality/defold-tweener/archive/refs/tags/5.zip ``` -------------------------------- ### Create GUI Animation Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Load and create a GUI animation state from a Lua table or JSON file. This function is used for animations applied to GUI elements. ```lua panthera.create_gui(animation_or_path, [template], [nodes]) ``` -------------------------------- ### Create GUI Animation from Lua Table Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Loads a GUI animation state from a Lua table containing animation data. The data should be required from a separate Lua module. ```lua -- Using Lua table with animation data local animation_data = require("animations.my_animation_data") local gui_animation = panthera.create_gui(animation_data) ``` -------------------------------- ### Create Game Object Animation from Lua Table Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Loads a Game Object animation state from a Lua table containing animation data. The data should be required from a separate Lua module. ```lua -- Using Lua table with animation data local animation_data = require("animations.my_animation_data") local go_animation = panthera.create_go(animation_data) ``` -------------------------------- ### panthera.play Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Plays a specified animation with given ID and optional playback configurations. ```APIDOC ## panthera.play ### Description Play an animation with specified ID and options. ### Method `panthera.play(animation_state, animation_id, [options])` ### Parameters #### Path Parameters - `animation_state` (object) - Required - The animation state object returned by `create_go` or `create_gui`. - `animation_id` (string) - Required - A string identifier for the animation to play. - `options` (table) - Optional - A table of playback options, as described in the [Animation Playback Options](#animation-playback-options) section. ### Usage Example ```lua panthera.play(go_animation_state, "walk", { is_loop = true, speed = 1 }) ``` ``` -------------------------------- ### panthera.create Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Creates a generic animation object. This is a versatile function for initializing animations. ```APIDOC ## panthera.create ### Description Creates a generic animation object. This is a versatile function for initializing animations. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua local animation_object = panthera.create() ``` ### Response Returns a generic animation object. ``` -------------------------------- ### Play Animation Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Play an animation with a specified ID and optional playback options. This function initiates the animation sequence on the provided animation state. ```lua panthera.play(animation_state, animation_id, [options]) ``` -------------------------------- ### set_logger Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Customize the logging mechanism used by Panthera Runtime. You can use Defold Log library or provide a custom logger. ```APIDOC ## set_logger ### Description Customize the logging mechanism used by Panthera Runtime. You can use Defold Log library or provide a custom logger. ### Method `panthera.set_logger` ### Parameters #### Arguments - `logger_instance` (table|panthera.logger)? - A logger object that follows the specified logging interface. Pass nil to use empty logger ``` -------------------------------- ### Set Panthera Logger Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Customize the logging mechanism used by Panthera Runtime. You can use Defold Log library or provide a custom logger. Pass nil to use an empty logger. ```lua panthera.set_logger([logger_instance]) ``` -------------------------------- ### Create Game Object Animation Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Load and create a game object animation state from a Lua table or JSON file. This function is used when animations are associated with game objects in a collection. ```lua panthera.create_go(animation_or_path, [collection_name], [objects]) ``` -------------------------------- ### panthera.set_logger Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Customizes the logging mechanism used by Panthera Runtime. Allows integration with Defold Log or custom logger implementations. ```APIDOC ## panthera.set_logger ### Description Customizes the logging mechanism used by **Panthera Runtime**. You can use **Defold Log** library or provide a custom logger. ### Method `panthera.set_logger(logger_instance)` ### Parameters #### Parameters - `logger_instance` (object) - Required - A logger object that follows the specified logging interface, including methods for `trace`, `debug`, `info`, `warn`, `error`. Pass `nil` to remove the default logger. ### Usage Example Using the [Defold Log](https://github.com/Insality/defold-log) module: ```lua local log = require("log.log") local panthera = require("panthera.panthera") panthera.set_logger(log.get_logger("panthera")) ``` Creating a custom user logger: ```lua local logger = { trace = function(_, message, context) end, debug = function(_, message, context) end, info = function(_, message, context) end, warn = function(_, message, context) end, error = function(_, message, context) end } panthera.set_logger(logger) ``` Remove the default logger: ```lua panthera.set_logger(nil) ``` ``` -------------------------------- ### panthera.is_playing Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Checks if an animation is currently playing. ```APIDOC ## panthera.is_playing ### Description Checks if an animation is currently playing. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua local playing = panthera.is_playing(animation_object) ``` ### Response Returns true if the animation is playing, false otherwise. ``` -------------------------------- ### Create Animation State with Lua Table Data Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Creates an animation state object using animation data defined in a Lua table and a specified adapter. This is useful for custom animation logic. ```lua local adapter = require("panthera.adapters.adapter_go") local animation_data = require("animations.my_animation_data") local go_animation_state = panthera.create(animation_data, adapter) ``` -------------------------------- ### Reload Animations Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Reloads animations from JSON files, primarily for development and debugging on desktop. Can reload all animations or a specific one. ```lua panthera.reload_animation([animation_path]) ``` -------------------------------- ### is_playing Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Check if an animation is currently playing. ```APIDOC ## is_playing ### Description Check if an animation is currently playing. ### Method `panthera.is_playing` ### Parameters #### Arguments - `animation_state` (panthera.animation) - The animation state object ### Returns - `playing` (boolean) - True if the animation is playing, false otherwise ``` -------------------------------- ### Reload Animations from JSON Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Reload animations from JSON files, useful for development. If no path is specified, all loaded animations are reloaded. Animations loaded from Lua tables are not affected. ```lua -- Reload single animation panthera.reload_animation("/animations/my_animation.json") ``` ```lua -- Reload all loaded animations panthera.reload_animation() ``` -------------------------------- ### is_playing Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Checks if an animation is currently playing. ```APIDOC ## is_playing ### Description Check if an animation is currently playing. ### Method ```lua panthera.is_playing(animation_state) ``` ### Parameters #### Path Parameters - **animation_state** (panthera.animation) - Required - The animation state object ### Returns #### Success Response - **is_playing** (boolean) - True if the animation is currently playing, false otherwise ``` -------------------------------- ### panthera.set_logger Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Sets a custom logger function for Panthera Runtime. Allows for custom logging behavior. ```APIDOC ## panthera.set_logger ### Description Sets a custom logger function for Panthera Runtime. Allows for custom logging behavior. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua local function custom_log(message) print("Panthera Log:", message) end panthera.set_logger(custom_log) ``` ### Response None explicitly documented. ``` -------------------------------- ### Simultaneous Animation Playback Source: https://github.com/insality/panthera/blob/main/docs/animation_blending.md Create and play two separate animation states concurrently. Ensure animations target different properties or nodes to avoid conflicts. This is useful for layering complex animations. ```lua local panthera = require("panthera.panthera") function init(self) -- Create two separate animation states for blending self.character_animation = panthera.create_go("/animations/character.json") self.character_details_animation = panthera.clone_state(self.character_animation) -- Start both animations to run at the same time panthera.play(self.character_animation, "walk", { is_loop = true }) panthera.play(self.character_details_animation, "eyes", { is_loop = true }) end ``` -------------------------------- ### Initialize Carousel Functionality Source: https://github.com/insality/panthera/blob/main/docs/index.html This JavaScript code initializes a carousel component, handling slide navigation, video playback control, and keyboard accessibility. It requires specific HTML attributes like 'data-carousel', 'data-track', 'data-prev', 'data-next', and 'data-dots'. ```javascript function(){ const carousel = document.querySelector('[data-carousel]'); if(!carousel) return; const track = carousel.querySelector('[data-track]'); const slides = Array.from(track.children); const prevBtn = carousel.querySelector('[data-prev]'); const nextBtn = carousel.querySelector('[data-next]'); const dotsWrap = carousel.querySelector('[data-dots]'); let index = 0; function update(){ track.style.transform = `translateX(-${index * 100}%)`; slides.forEach((s,i)=>{ const v = s.querySelector('video'); if(!v) return; if(i === index){ try{ v.play(); } catch(_){} } else { v.pause(); v.currentTime = 0; } }); if(dotsWrap){ Array.from(dotsWrap.children).forEach((d,i)=>d.classList.toggle('active', i===index)); } } // Dots slides.forEach((_,i)=>{ const b = document.createElement('button'); b.setAttribute('aria-label', `Slide ${i+1}`); b.addEventListener('click', ()=>{ index = i; update(); }); dotsWrap.appendChild(b); }); prevBtn.addEventListener('click', ()=>{ index = (index-1+slides.length)%slides.length; update(); }); nextBtn.addEventListener('click', ()=>{ index = (index+1)%slides.length; update(); }); // Keyboard carousel.addEventListener('keydown', (e)=>{ if(e.key==='ArrowLeft'){ prevBtn.click(); } if(e.key==='ArrowRight'){ nextBtn.click(); } }); update(); }() ``` -------------------------------- ### Set Panthera Logger Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Customize the logging mechanism used by Panthera Runtime. Pass a logger object with trace, debug, info, warn, and error methods, or nil to remove the default logger. ```lua panthera.set_logger(logger_instance) ``` ```lua local log = require("log.log") local panthera = require("panthera.panthera") panthera.set_logger(log.get_logger("panthera")) ``` ```lua local logger = { trace = function(_, message, context) end, debug = function(_, message, context) end, info = function(_, message, context) end, warn = function(_, message, context) end, error = function(_, message, context) end } panthera.set_logger(logger) ``` ```lua panthera.set_logger(nil) ``` -------------------------------- ### get_animations Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Returns a list of animation IDs from the created animation state. ```APIDOC ## get_animations ### Description Return a list of animation IDs from the created animation state. ### Method ```lua panthera.get_animations(animation_state) ``` ### Parameters #### Path Parameters - **animation_state** (panthera.animation) - Required - The animation state object ### Returns #### Success Response - **animation_ids** (string[]) - Array of animation IDs available in the animation state ``` -------------------------------- ### panthera.set_time Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Sets the current playback time of an animation. Allows seeking to a specific point in the animation. ```APIDOC ## panthera.set_time ### Description Sets the current playback time of an animation. Allows seeking to a specific point in the animation. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua panthera.set_time(animation_object, time_in_seconds) ``` ### Response None explicitly documented. ``` -------------------------------- ### Clone Animation State Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Clone an existing animation state object. This allows multiple independent instances of the same animation to play simultaneously. ```lua panthera.clone_state(animation_state) ``` -------------------------------- ### clone_state Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Clone an existing animation state object, enabling multiple instances of the same animation to play simultaneously or independently. ```APIDOC ## clone_state ### Description Clone an existing animation state object, enabling multiple instances of the same animation to play simultaneously or independently. ### Method `panthera.clone_state` ### Parameters #### Arguments - `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.clone_state Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Clones an existing animation state object. This allows for multiple independent instances of the same animation to be played simultaneously. ```APIDOC ## panthera.clone_state ### Description Clone an existing animation state object, enabling multiple instances of the same animation to play simultaneously or independently. ### Method `panthera.clone_state(animation_state)` ### Parameters #### Path Parameters - `animation_state` (object) - Required - The animation state object to clone. ### Returns - A new animation state object that is a copy of the original. ### Usage Example ```lua local go_animation_state = panthera.create_go("/animations/player_animation.json") local cloned_state = panthera.clone_state(go_animation_state) ``` ``` -------------------------------- ### Check if Animation is Playing Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Determines if an animation is currently in progress. Returns a boolean indicating the playback status. ```lua panthera.is_playing(animation_state) ``` -------------------------------- ### get_time Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Retrieve the current playback time in seconds of an animation. If the animation is not playing, the function returns 0. ```APIDOC ## get_time ### Description Retrieve the current playback time in seconds of an animation. If the animation is not playing, the function returns 0. ### Method `panthera.get_time` ### Parameters #### Arguments - `animation_state` (panthera.animation) - The animation state object ### Returns - `seconds` (number) - Current animation time in seconds ``` -------------------------------- ### panthera.reload_animation Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Reloads the animation data. Use this to refresh the animation if its source has changed. ```APIDOC ## panthera.reload_animation ### Description Reloads the animation data. Use this to refresh the animation if its source has changed. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua panthera.reload_animation(animation_object) ``` ### Response None explicitly documented. ``` -------------------------------- ### stop Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Stops the currently playing animation. ```APIDOC ## stop ### Description Stops the currently playing animation. ### Method `panthera.stop` ### Parameters #### Arguments - `animation_state` (panthera.animation) - The animation state object ``` -------------------------------- ### stop Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Stops a currently playing animation at its current time. ```APIDOC ## stop ### Description Stops a currently playing animation. The animation will be stopped at its current time. ### Method ```lua panthera.stop(animation_state) ``` ### Parameters #### Path Parameters - **animation_state** (panthera.animation) - Required - The animation state object to stop ### Returns #### Success Response - **is_stopped** (boolean) - True if animation was stopped, false if animation is not playing ``` -------------------------------- ### reload_animation Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Reloads animations from JSON files, useful for development and debugging. ```APIDOC ## reload_animation ### Description 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. ### Method ```lua panthera.reload_animation([animation_path]) ``` ### Parameters #### Path Parameters - **animation_path** (string?) - Optional - Specific animation to reload. If omitted, all loaded animations are reloaded ``` -------------------------------- ### panthera.clone_state Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Clones the current state of an animation. Useful for saving and restoring animation states. ```APIDOC ## panthera.clone_state ### Description Clones the current state of an animation. Useful for saving and restoring animation states. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua local cloned_state = panthera.clone_state(animation_object) ``` ### Response Returns a copy of the animation's current state. ``` -------------------------------- ### Stop Animation Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Stops a currently playing animation at its current time. Use this when you need to halt an animation immediately. ```lua panthera.stop(animation_state) ``` -------------------------------- ### Stop Animation Playback Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Call this function to halt a currently playing animation. It requires the animation state object. ```lua panthera.stop(animation_state) ``` ```lua panthera.stop(go_animation_state) ``` -------------------------------- ### get_duration Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Retrieves the total duration of a specific animation. ```APIDOC ## get_duration ### Description Retrieve the total duration of a specific animation. ### Method ```lua panthera.get_duration(animation_state, animation_id) ``` ### Parameters #### Path Parameters - **animation_state** (panthera.animation) - Required - The animation state object - **animation_id** (string) - Required - The ID of the animation whose duration you want to retrieve ### Returns #### Success Response - **seconds** (number) - The total duration of the animation in seconds ``` -------------------------------- ### Set Animation Time Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Set the current playback time of an animation. This function stops any currently playing animation and seeks to the specified time. It returns true on success and false otherwise. ```lua panthera.set_time(animation_state, animation_id, time, [event_callback]) ``` -------------------------------- ### Set Animation Playback Time Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Directly set the current playback time of an animation. This stops any current playback and updates the state to the specified time. ```lua panthera.set_time(animation_state, animation_id, time) ``` ```lua -- Set the animation to start playing from 2 seconds in panthera.set_time(self.go_animation, "run", 2) ``` -------------------------------- ### panthera.stop Source: https://github.com/insality/panthera/blob/main/API_REFERENCE.md Stops an animation. This function halts the playback of an animation. ```APIDOC ## panthera.stop ### Description Stops an animation. This function halts the playback of an animation. ### Method Not applicable (SDK function) ### Parameters None explicitly documented. ### Request Example ```lua panthera.stop(animation_object) ``` ### Response None explicitly documented. ``` -------------------------------- ### set_time Source: https://github.com/insality/panthera/blob/main/api/panthera_api.md Set the current time of an animation. This function stops any currently playing animation. ```APIDOC ## set_time ### Description Set the current time of an animation. This function stops any currently playing animation. ### Method `panthera.set_time` ### Parameters #### Arguments - `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 ```