Panthera Runtime - a Defold library designed to integrate animations created with Panthera 2.0 Editor, a versatile animation software, into Defold projects. This runtime library simplifies the process of importing and playing back Panthera animations, enhancing the visual quality and interactivity of Defold games and applications.
- Seamless Animation Integration: Import and use Panthera 2.0 animations directly in Defold.
- Full Animation Support: Supports all animation features provided by Panthera 2.0, including events, animation blending, nested animations and more.
- Flexible Usage: Compatible with both Game Objects and GUI nodes in Defold, allowing for versatile application across different game elements.
- Animation Cursor: Provides a way to control animation manually, allowing for precise control over playback and synchronization with game events.
- Hot Reloading: Reload animations on the fly during development, enabling rapid iteration and testing of animation assets.
Read the Panthera 2.0 Editor guide to learn about the Panthera 2.0 Editor, an innovative tool developed using the Defold engine, designed to simplify and enhance the creation of animations for Defold projects.
Open your game.project
file and add the following lines to the dependencies field under the project section:
https://github.com/Insality/defold-tweener/archive/refs/tags/3.zip
https://github.com/Insality/panthera/archive/refs/tags/runtime.4.zip
After that, select Project ▸ Fetch Libraries
to update library dependencies. This happens automatically whenever you open a project so you will only need to do this if the dependencies change without re-opening the project.
Note: The library size is calculated based on the build report per platform
Platform | Library Size |
---|---|
HTML5 | 12.42 KB |
Desktop / Mobile | 21.35 KB |
Note: Hot reloading is designed for use in development environments only. Hot reloading only works for animations from JSON files. If you using a lua table for animations, hot reloading will not work.
Panthera Runtime supports hot reloading of animations for a more efficient development workflow. This feature allows animations to be reloaded automatically without restarting your Defold game, facilitating rapid iteration on animation assets.
To enable hot reloading of animations, include the following settings in your game.project
file:
[panthera]
hotreload_animations = 1
Configuration Details:
- hotreload_animations: Set to
1
to enable hot reloading. This feature is active only in debug mode.
Implementing Hot Reload in Defold:
To utilize hot reloading, set up a window event listener in your Defold script that triggers panthera.reload_animation()
when the game window gains focus. This ensures that animations are refreshed automatically during development:
local panthera = require("panthera.panthera")
-- Reload animation when window is focused, only for debug and on desktop
window.set_listener(function(_, event)
if event == window.WINDOW_EVENT_FOCUS_GAINED then
panthera.reload_animation()
end
end)
panthera.create_gui(animation_path_or_data, [template], [nodes])
panthera.create_go(animation_path_or_data, [collection_name], [objects])
panthera.create(animation_path_or_data, adapter, get_node)
panthera.clone_state(animation_state)
panthera.play(animation_state, animation_id, [options])
panthera.stop(animation_state)
panthera.set_time(animation_state, animation_id, time)
panthera.get_time(animation_state)
panthera.get_duration(animation_state, animation_id)
panthera.is_playing(animation_state)
panthera.get_latest_animation_id(animation_state)
panthera.set_logger([logger_instance])
panthera.reload_animation([animation_path])
Read the API Reference file to see the full API documentation for the module.
Integrate Panthera animations into Defold with these concise examples:
Load and play a animation file using the GO adapter.
local panthera = require("panthera.panthera")
local animation = require("path.to.panthera_animation")
function init(self)
self.animation = panthera.create_go(animation)
panthera.play(self.animation, "run", { is_loop = true })
end
This example applies a looping run animation to a game object when the game starts.
Load and play a animation file using the GUI adapter.
local panthera = require("panthera.panthera")
local animation = require("path.to.panthera_animation")
function init(self)
self.animation = panthera.create_gui(animation)
panthera.play(self.animation, "fade_in")
end
This example applies a fade-in animation to a GUI node when the game starts
Check if an animation is currently playing and retrieve the current animation ID.
local panthera = require("panthera.panthera")
function init(self)
-- You can use JSON instead of Lua tables, but it should be accessible with sys.load_resource()
self.animation = panthera.create_gui("/animations/animation.json")
local is_playing = panthera.is_playing(self.animation)
local animation_id = panthera.get_latest_animation_id(self.animation)
if is_playing then
print("The animation is currently playing: ", animation_id)
else
print("The animation is not playing")
end
end
When integrating Panthera 2.0 animations with Defold game objects (GOs), it's essential to know which properties you can animate:
By default, sprite components uses the tint
property and label components use the color
property. Panthera try to use color
property. To enable color
property you should set the material of sprite component to /panthera/materials/sprite.material
or use any other material with color
attribute.
- Position: Move objects.
- Rotation: Rotate objects.
- Scale: Scale objects.
- Color: Update color of sprite or Text component.
- Slice9: Update slice9 properties of sprite component.
- Size: Update size of sprite component.
- Text: Update text content of label component.
- Texture: Switch textures of sprite component.
- Enabled: Toggle object enabled/disabled.
Read the Animation Blending guide to learn how to blend multiple animations simultaneously on the same entity, creating complex, layered animations that enhance the visual fidelity and dynamism of your game.
While Panthera Runtime provides a default adapter for game objects and GUI, you might need to customize your adapter based on your project's needs. Read the Customizing Your Adapter guide to learn how to map easing types, handle custom events, and use your custom adapter with Panthera Runtime.
Panthera Runtime is licensed under the MIT License - see the LICENSE file for details.
For any issues, questions, or suggestions, please create an issue.
Read the CHANGELOG to learn about the latest updates and features in Panthera Runtime.
Your support motivates me to keep creating and maintaining projects for Defold. Consider supporting if you find my projects helpful and valuable.