
Panthera Runtime -Defold Library旨在将与多功能动画软件Panthera 2.0编辑器创建的动画集成到偏斜的项目中。此运行时库简化了导入和播放Panthera动画的过程,从而增强了Defold Games和应用程序的视觉质量和交互性。
阅读《 Panthera 2.0编辑指南》,以了解Panthera 2.0编辑器,这是一种使用Defold Engine开发的创新工具,旨在简化和增强为Defold Projects创建动画的创建。
打开您的game.project文件,并将以下行添加到项目部分下的依赖项字段:
Defold Tweener
https://github.com/Insality/defold-tweener/archive/refs/tags/3.zip
Panthera运行时
https://github.com/Insality/panthera/archive/refs/tags/runtime.4.zip
之后,选择Project ▸ Fetch Libraries以更新库依赖关系。每当您打开一个项目时,这种情况就会自动发生,因此,只有依赖项在不重新打开项目的情况下更改时,您才需要执行此操作。
注意:库大小是根据每个平台的构建报告计算的
| 平台 | 库大小 |
|---|---|
| HTML5 | 12.42 kb |
| 桌面 /手机 | 21.35 kb |
注意: Hot Reloading旨在仅在开发环境中使用。热重新加载仅适用于JSON文件中的动画。如果您使用LUA表进行动画,则热重载将无法使用。
Panthera Runtime支持动画的热加载,以提供更有效的开发工作流程。此功能允许自动重新加载动画,而无需重新启动您的偏移游戏,从而促进了动画资产的快速迭代。
要启用动画的热加载,请在您的game.project中包含以下设置。项目文件:
[panthera]
hotreload_animations = 1配置详细信息:
1以启用热装加载。此功能仅在调试模式下活动。在Defold中实施热装加载:
要利用热重新加载,请在您的Defold脚本中设置一个窗口事件侦听器,该脚本会触发panthera.reload_animation()当游戏窗口获得焦点时。这样可以确保在开发过程中自动刷新动画:
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 ])读取API参考文件以查看模块的完整API文档。
将Panthera动画与以下简洁的示例相结合:
使用GO适配器加载并播放动画文件。
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当游戏启动时,此示例将循环运行动画应用于游戏对象。
使用GUI适配器加载并播放动画文件。
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游戏开始时,此示例将淡入动画应用于GUI节点
检查动画当前正在播放并检索当前动画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将Panthera 2.0动画与Defold Game对象(GOS)集成在一起时,必须知道可以动画的属性:
默认情况下,Sprite组件使用tint属性和标签组件使用color属性。 Panthera尝试使用color属性。要启用color属性,您应该将Sprite组件的材料设置为/panthera/materials/sprite.material或使用任何其他具有color属性的材料。
阅读动画混合指南,以了解如何同时在同一实体上同时融合多个动画,从而创建复杂的分层动画,从而增强游戏的视觉效果和动态。
尽管Panthera运行时为游戏对象和GUI提供了默认的适配器,但您可能需要根据项目的需求自定义适配器。阅读自定义适配器指南,以了解如何映射放松类型,处理自定义事件,并使用Panthera运行时使用自定义适配器。
Panthera运行时是根据MIT许可证获得许可的 - 有关详细信息,请参见许可证文件。
对于任何问题,问题或建议,请创建一个问题。
阅读ChangElog,以了解Panthera运行时的最新更新和功能。
您的支持激发了我继续创建和维护项目以使其偏斜。如果您发现我的项目有帮助且有价值,请考虑支持。