diff options
Diffstat (limited to 'scene/2d/animated_sprite.h')
-rw-r--r-- | scene/2d/animated_sprite.h | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h index cd00a4e181..37d093e3d8 100644 --- a/scene/2d/animated_sprite.h +++ b/scene/2d/animated_sprite.h @@ -42,7 +42,7 @@ class SpriteFrames : public Resource { float speed; bool loop; - Vector<Ref<Texture> > frames; + Vector<Ref<Texture2D> > frames; Anim() { loop = true; @@ -50,8 +50,12 @@ class SpriteFrames : public Resource { } StringName normal_name; + StringName specular_name; }; + Color specular_color; + float shininess; + Map<StringName, Anim> animations; Array _get_frames() const; @@ -80,34 +84,48 @@ public: void set_animation_loop(const StringName &p_anim, bool p_loop); bool get_animation_loop(const StringName &p_anim) const; - void add_frame(const StringName &p_anim, const Ref<Texture> &p_frame, int p_at_pos = -1); + void add_frame(const StringName &p_anim, const Ref<Texture2D> &p_frame, int p_at_pos = -1); int get_frame_count(const StringName &p_anim) const; - _FORCE_INLINE_ Ref<Texture> get_frame(const StringName &p_anim, int p_idx) const { + _FORCE_INLINE_ Ref<Texture2D> get_frame(const StringName &p_anim, int p_idx) const { const Map<StringName, Anim>::Element *E = animations.find(p_anim); - ERR_FAIL_COND_V_MSG(!E, Ref<Texture>(), "Animation '" + String(p_anim) + "' doesn't exist."); - ERR_FAIL_COND_V(p_idx < 0, Ref<Texture>()); + ERR_FAIL_COND_V_MSG(!E, Ref<Texture2D>(), "Animation '" + String(p_anim) + "' doesn't exist."); + ERR_FAIL_COND_V(p_idx < 0, Ref<Texture2D>()); if (p_idx >= E->get().frames.size()) - return Ref<Texture>(); + return Ref<Texture2D>(); return E->get().frames[p_idx]; } - _FORCE_INLINE_ Ref<Texture> get_normal_frame(const StringName &p_anim, int p_idx) const { + _FORCE_INLINE_ Ref<Texture2D> 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_MSG(!E, Ref<Texture>(), "Animation '" + String(p_anim) + "' doesn't exist."); - ERR_FAIL_COND_V(p_idx < 0, Ref<Texture>()); + ERR_FAIL_COND_V_MSG(!E, Ref<Texture2D>(), "Animation '" + String(p_anim) + "' doesn't exist."); + ERR_FAIL_COND_V(p_idx < 0, Ref<Texture2D>()); const Map<StringName, Anim>::Element *EN = animations.find(E->get().normal_name); if (!EN || p_idx >= EN->get().frames.size()) - return Ref<Texture>(); + return Ref<Texture2D>(); + + return EN->get().frames[p_idx]; + } + + _FORCE_INLINE_ Ref<Texture2D> get_specular_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<Texture2D>()); + ERR_FAIL_COND_V(p_idx < 0, Ref<Texture2D>()); + + const Map<StringName, Anim>::Element *EN = animations.find(E->get().specular_name); + + if (!EN || p_idx >= EN->get().frames.size()) + return Ref<Texture2D>(); return EN->get().frames[p_idx]; } - void set_frame(const StringName &p_anim, int p_idx, const Ref<Texture> &p_frame) { + void set_frame(const StringName &p_anim, int p_idx, const Ref<Texture2D> &p_frame) { Map<StringName, Anim>::Element *E = animations.find(p_anim); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist."); ERR_FAIL_COND(p_idx < 0); @@ -150,6 +168,9 @@ class AnimatedSprite : public Node2D { bool _is_playing() const; Rect2 _get_rect() const; + Color specular_color; + float shininess; + protected: static void _bind_methods(); void _notification(int p_what); @@ -197,8 +218,11 @@ public: void set_flip_v(bool p_flip); bool is_flipped_v() const; - void set_modulate(const Color &p_color); - Color get_modulate() const; + void set_specular_color(const Color &p_color); + Color get_specular_color() const; + + void set_shininess(float p_shininess); + float get_shininess() const; virtual String get_configuration_warning() const; AnimatedSprite(); |