diff options
Diffstat (limited to 'scene/2d/animated_sprite.h')
-rw-r--r-- | scene/2d/animated_sprite.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h index 64794b0ca3..2274450647 100644 --- a/scene/2d/animated_sprite.h +++ b/scene/2d/animated_sprite.h @@ -47,6 +47,8 @@ class SpriteFrames : public Resource { loop = true; speed = 5; } + + StringName normal_name; }; Map<StringName, Anim> animations; @@ -89,6 +91,20 @@ public: return E->get().frames[p_idx]; } + _FORCE_INLINE_ Ref<Texture> get_normal_frame(const StringName &p_anim, int p_idx) const { + + const Map<StringName, Anim>::Element *E = animations.find(p_anim); + ERR_FAIL_COND_V(!E, Ref<Texture>()); + ERR_FAIL_COND_V(p_idx < 0, Ref<Texture>()); + + const Map<StringName, Anim>::Element *EN = animations.find(E->get().normal_name); + + if (p_idx >= EN->get().frames.size()) + return Ref<Texture>(); + + return EN->get().frames[p_idx]; + } + void set_frame(const StringName &p_anim, int p_idx, const Ref<Texture> &p_frame) { Map<StringName, Anim>::Element *E = animations.find(p_anim); ERR_FAIL_COND(!E); |