Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
AnimatedTexture
已棄用: This class does not work properly in current versions and may be removed in the future. There is currently no equivalent workaround.
繼承: Texture2D < Texture < Resource < RefCounted < Object
用於簡單影格動畫的代理紋理。
說明
AnimatedTexture 是影格式動畫的資源格式,可讓多張紋理依每影格預設的延遲自動串接播放。與 AnimationPlayer 或 AnimatedSprite2D 不同,它不是 Node,因此可在任何接受 Texture2D 的地方使用,例如 TileSet。
動畫播放受 speed_scale 與各影格持續時間(見 set_frame_duration())控制。動畫會循環播放,播放完最後一影格後會自動回到影格 0。
AnimatedTexture 要求所有影格的紋理尺寸相同,否則尺寸較大的影格將被裁切以符合最小尺寸。
注意:AnimatedTexture 不支援 AtlasTexture;每一影格必須是獨立的 Texture2D。
警告: 目前的實作對現代繪圖管線的效率不佳。
屬性
|
||
|
||
|
||
resource_local_to_scene |
|
|
|
方法
get_frame_duration(frame: int) const |
|
get_frame_texture(frame: int) const |
|
void |
set_frame_duration(frame: int, duration: float) |
void |
set_frame_texture(frame: int, texture: Texture2D) |
常數
MAX_FRAMES = 256 🔗
「AnimatedTexture」可支援的最大影格數;若動畫需要更多影格,請改用 AnimationPlayer 或 AnimatedSprite2D。
屬性說明
設定目前可見的影格;在播放期間設定會重設該影格計時,因而讓新選擇的影格完整播放其設定的持續時間。
動畫所使用的影格總數。雖可透過 set_frame_texture() 個別新增影格,但仍須設定此值才能讓動畫納入新影格。最大值為 MAX_FRAMES。
若為 true,動畫僅播放一次,結束後不會回到第一影格;到達末尾並不會自動將 pause 設為 true。
若為 true,動畫會在目前位置(current_frame)暫停;改回 false 時會從該處繼續播放。
動畫速度會乘以此值;若為負值則反向播放。
方法說明
float get_frame_duration(frame: int) const 🔗
回傳指定 frame 的持續時間(秒)。
Texture2D get_frame_texture(frame: int) const 🔗
回傳指定影格的 Texture2D。
void set_frame_duration(frame: int, duration: float) 🔗
設定指定 frame 的持續時間,最終時間會再乘以 speed_scale。若設為 0,播放時會跳過該影格。
void set_frame_texture(frame: int, texture: Texture2D) 🔗
將 Texture2D 指定給目標影格。影格 ID 從 0 開始,第一格為 0,最後一格為 frames - 1。
最多可設定 MAX_FRAMES 張紋理,但只有 0 至 frames - 1 的影格會參與播放。