
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運行時的最新更新和功能。
您的支持激發了我繼續創建和維護項目以使其偏斜。如果您發現我的項目有幫助且有價值,請考慮支持。