diff options
author | Juan Linietsky <reduzio@gmail.com> | 2020-03-26 18:49:16 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-03-27 14:54:04 +0100 |
commit | eaae4b6408361eb34363adcb22a08046f43147f4 (patch) | |
tree | 4baf4cd8758696d260bef2cb149e27bf3135a284 /scene/2d | |
parent | 9a7dbc2acafdd04ff0fe09bc5f4838b4920348a8 (diff) |
Renamed 2D and 3D nodes to make their types explicit
Fixes #30736.
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/animated_sprite_2d.cpp (renamed from scene/2d/animated_sprite.cpp) | 142 | ||||
-rw-r--r-- | scene/2d/animated_sprite_2d.h (renamed from scene/2d/animated_sprite.h) | 12 | ||||
-rw-r--r-- | scene/2d/sprite_2d.cpp (renamed from scene/2d/sprite.cpp) | 176 | ||||
-rw-r--r-- | scene/2d/sprite_2d.h (renamed from scene/2d/sprite.h) | 14 | ||||
-rw-r--r-- | scene/2d/visibility_notifier_2d.cpp | 6 |
5 files changed, 175 insertions, 175 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite_2d.cpp index f3f7ba9ddd..4cedfc0c20 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* animated_sprite.cpp */ +/* animated_sprite_2d.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "animated_sprite.h" +#include "animated_sprite_2d.h" #include "core/os/os.h" #include "scene/scene_string_names.h" @@ -37,35 +37,35 @@ #define SPECULAR_SUFFIX "_specular" #ifdef TOOLS_ENABLED -Dictionary AnimatedSprite::_edit_get_state() const { +Dictionary AnimatedSprite2D::_edit_get_state() const { Dictionary state = Node2D::_edit_get_state(); state["offset"] = offset; return state; } -void AnimatedSprite::_edit_set_state(const Dictionary &p_state) { +void AnimatedSprite2D::_edit_set_state(const Dictionary &p_state) { Node2D::_edit_set_state(p_state); set_offset(p_state["offset"]); } -void AnimatedSprite::_edit_set_pivot(const Point2 &p_pivot) { +void AnimatedSprite2D::_edit_set_pivot(const Point2 &p_pivot) { set_offset(get_offset() - p_pivot); set_position(get_transform().xform(p_pivot)); } -Point2 AnimatedSprite::_edit_get_pivot() const { +Point2 AnimatedSprite2D::_edit_get_pivot() const { return Vector2(); } -bool AnimatedSprite::_edit_use_pivot() const { +bool AnimatedSprite2D::_edit_use_pivot() const { return true; } -Rect2 AnimatedSprite::_edit_get_rect() const { +Rect2 AnimatedSprite2D::_edit_get_rect() const { return _get_rect(); } -bool AnimatedSprite::_edit_use_rect() const { +bool AnimatedSprite2D::_edit_use_rect() const { if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) { return false; } @@ -76,11 +76,11 @@ bool AnimatedSprite::_edit_use_rect() const { } #endif -Rect2 AnimatedSprite::get_anchorable_rect() const { +Rect2 AnimatedSprite2D::get_anchorable_rect() const { return _get_rect(); } -Rect2 AnimatedSprite::_get_rect() const { +Rect2 AnimatedSprite2D::_get_rect() const { if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) { return Rect2(); } @@ -328,7 +328,7 @@ SpriteFrames::SpriteFrames() { add_animation(SceneStringNames::get_singleton()->_default); } -void AnimatedSprite::_validate_property(PropertyInfo &property) const { +void AnimatedSprite2D::_validate_property(PropertyInfo &property) const { if (!frames.is_valid()) return; @@ -370,7 +370,7 @@ void AnimatedSprite::_validate_property(PropertyInfo &property) const { } } -void AnimatedSprite::_notification(int p_what) { +void AnimatedSprite2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_INTERNAL_PROCESS: { @@ -472,13 +472,13 @@ void AnimatedSprite::_notification(int p_what) { } } -void AnimatedSprite::set_sprite_frames(const Ref<SpriteFrames> &p_frames) { +void AnimatedSprite2D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) { if (frames.is_valid()) - frames->disconnect("changed", callable_mp(this, &AnimatedSprite::_res_changed)); + frames->disconnect("changed", callable_mp(this, &AnimatedSprite2D::_res_changed)); frames = p_frames; if (frames.is_valid()) - frames->connect("changed", callable_mp(this, &AnimatedSprite::_res_changed)); + frames->connect("changed", callable_mp(this, &AnimatedSprite2D::_res_changed)); if (!frames.is_valid()) { frame = 0; @@ -492,12 +492,12 @@ void AnimatedSprite::set_sprite_frames(const Ref<SpriteFrames> &p_frames) { update_configuration_warning(); } -Ref<SpriteFrames> AnimatedSprite::get_sprite_frames() const { +Ref<SpriteFrames> AnimatedSprite2D::get_sprite_frames() const { return frames; } -void AnimatedSprite::set_frame(int p_frame) { +void AnimatedSprite2D::set_frame(int p_frame) { if (!frames.is_valid()) { return; @@ -521,12 +521,12 @@ void AnimatedSprite::set_frame(int p_frame) { _change_notify("frame"); emit_signal(SceneStringNames::get_singleton()->frame_changed); } -int AnimatedSprite::get_frame() const { +int AnimatedSprite2D::get_frame() const { return frame; } -void AnimatedSprite::set_speed_scale(float p_speed_scale) { +void AnimatedSprite2D::set_speed_scale(float p_speed_scale) { float elapsed = _get_frame_duration() - timeout; @@ -537,56 +537,56 @@ void AnimatedSprite::set_speed_scale(float p_speed_scale) { timeout -= elapsed; } -float AnimatedSprite::get_speed_scale() const { +float AnimatedSprite2D::get_speed_scale() const { return speed_scale; } -void AnimatedSprite::set_centered(bool p_center) { +void AnimatedSprite2D::set_centered(bool p_center) { centered = p_center; update(); item_rect_changed(); } -bool AnimatedSprite::is_centered() const { +bool AnimatedSprite2D::is_centered() const { return centered; } -void AnimatedSprite::set_offset(const Point2 &p_offset) { +void AnimatedSprite2D::set_offset(const Point2 &p_offset) { offset = p_offset; update(); item_rect_changed(); _change_notify("offset"); } -Point2 AnimatedSprite::get_offset() const { +Point2 AnimatedSprite2D::get_offset() const { return offset; } -void AnimatedSprite::set_flip_h(bool p_flip) { +void AnimatedSprite2D::set_flip_h(bool p_flip) { hflip = p_flip; update(); } -bool AnimatedSprite::is_flipped_h() const { +bool AnimatedSprite2D::is_flipped_h() const { return hflip; } -void AnimatedSprite::set_flip_v(bool p_flip) { +void AnimatedSprite2D::set_flip_v(bool p_flip) { vflip = p_flip; update(); } -bool AnimatedSprite::is_flipped_v() const { +bool AnimatedSprite2D::is_flipped_v() const { return vflip; } -void AnimatedSprite::_res_changed() { +void AnimatedSprite2D::_res_changed() { set_frame(frame); _change_notify("frame"); @@ -594,7 +594,7 @@ void AnimatedSprite::_res_changed() { update(); } -void AnimatedSprite::_set_playing(bool p_playing) { +void AnimatedSprite2D::_set_playing(bool p_playing) { if (playing == p_playing) return; @@ -603,12 +603,12 @@ void AnimatedSprite::_set_playing(bool p_playing) { set_process_internal(playing); } -bool AnimatedSprite::_is_playing() const { +bool AnimatedSprite2D::_is_playing() const { return playing; } -void AnimatedSprite::play(const StringName &p_animation, const bool p_backwards) { +void AnimatedSprite2D::play(const StringName &p_animation, const bool p_backwards) { backwards = p_backwards; @@ -621,17 +621,17 @@ void AnimatedSprite::play(const StringName &p_animation, const bool p_backwards) _set_playing(true); } -void AnimatedSprite::stop() { +void AnimatedSprite2D::stop() { _set_playing(false); } -bool AnimatedSprite::is_playing() const { +bool AnimatedSprite2D::is_playing() const { return playing; } -float AnimatedSprite::_get_frame_duration() { +float AnimatedSprite2D::_get_frame_duration() { if (frames.is_valid() && frames->has_animation(animation)) { float speed = frames->get_animation_speed(animation) * speed_scale; if (speed > 0) { @@ -641,7 +641,7 @@ float AnimatedSprite::_get_frame_duration() { return 0.0; } -void AnimatedSprite::_reset_timeout() { +void AnimatedSprite2D::_reset_timeout() { if (!playing) return; @@ -650,7 +650,7 @@ void AnimatedSprite::_reset_timeout() { is_over = false; } -void AnimatedSprite::set_animation(const StringName &p_animation) { +void AnimatedSprite2D::set_animation(const StringName &p_animation) { ERR_FAIL_COND_MSG(frames == NULL, vformat("There is no animation with name '%s'.", p_animation)); ERR_FAIL_COND_MSG(frames->get_animation_names().find(p_animation) == -1, vformat("There is no animation with name '%s'.", p_animation)); @@ -664,12 +664,12 @@ void AnimatedSprite::set_animation(const StringName &p_animation) { _change_notify(); update(); } -StringName AnimatedSprite::get_animation() const { +StringName AnimatedSprite2D::get_animation() const { return animation; } -String AnimatedSprite::get_configuration_warning() const { +String AnimatedSprite2D::get_configuration_warning() const { if (frames.is_null()) { return TTR("A SpriteFrames resource must be created or set in the \"Frames\" property in order for AnimatedSprite to display frames."); @@ -678,62 +678,62 @@ String AnimatedSprite::get_configuration_warning() const { return String(); } -void AnimatedSprite::set_specular_color(const Color &p_color) { +void AnimatedSprite2D::set_specular_color(const Color &p_color) { specular_color = p_color; update(); } -Color AnimatedSprite::get_specular_color() const { +Color AnimatedSprite2D::get_specular_color() const { return specular_color; } -void AnimatedSprite::set_shininess(float p_shininess) { +void AnimatedSprite2D::set_shininess(float p_shininess) { shininess = CLAMP(p_shininess, 0.0, 1.0); update(); } -float AnimatedSprite::get_shininess() const { +float AnimatedSprite2D::get_shininess() const { return shininess; } -void AnimatedSprite::_bind_methods() { +void AnimatedSprite2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite::set_sprite_frames); - ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite::get_sprite_frames); + ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite2D::set_sprite_frames); + ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite2D::get_sprite_frames); - ClassDB::bind_method(D_METHOD("set_animation", "animation"), &AnimatedSprite::set_animation); - ClassDB::bind_method(D_METHOD("get_animation"), &AnimatedSprite::get_animation); + ClassDB::bind_method(D_METHOD("set_animation", "animation"), &AnimatedSprite2D::set_animation); + ClassDB::bind_method(D_METHOD("get_animation"), &AnimatedSprite2D::get_animation); - ClassDB::bind_method(D_METHOD("_set_playing", "playing"), &AnimatedSprite::_set_playing); - ClassDB::bind_method(D_METHOD("_is_playing"), &AnimatedSprite::_is_playing); + ClassDB::bind_method(D_METHOD("_set_playing", "playing"), &AnimatedSprite2D::_set_playing); + ClassDB::bind_method(D_METHOD("_is_playing"), &AnimatedSprite2D::_is_playing); - ClassDB::bind_method(D_METHOD("play", "anim", "backwards"), &AnimatedSprite::play, DEFVAL(StringName()), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("stop"), &AnimatedSprite::stop); - ClassDB::bind_method(D_METHOD("is_playing"), &AnimatedSprite::is_playing); + ClassDB::bind_method(D_METHOD("play", "anim", "backwards"), &AnimatedSprite2D::play, DEFVAL(StringName()), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("stop"), &AnimatedSprite2D::stop); + ClassDB::bind_method(D_METHOD("is_playing"), &AnimatedSprite2D::is_playing); - ClassDB::bind_method(D_METHOD("set_centered", "centered"), &AnimatedSprite::set_centered); - ClassDB::bind_method(D_METHOD("is_centered"), &AnimatedSprite::is_centered); + ClassDB::bind_method(D_METHOD("set_centered", "centered"), &AnimatedSprite2D::set_centered); + ClassDB::bind_method(D_METHOD("is_centered"), &AnimatedSprite2D::is_centered); - ClassDB::bind_method(D_METHOD("set_offset", "offset"), &AnimatedSprite::set_offset); - ClassDB::bind_method(D_METHOD("get_offset"), &AnimatedSprite::get_offset); + ClassDB::bind_method(D_METHOD("set_offset", "offset"), &AnimatedSprite2D::set_offset); + ClassDB::bind_method(D_METHOD("get_offset"), &AnimatedSprite2D::get_offset); - ClassDB::bind_method(D_METHOD("set_flip_h", "flip_h"), &AnimatedSprite::set_flip_h); - ClassDB::bind_method(D_METHOD("is_flipped_h"), &AnimatedSprite::is_flipped_h); + ClassDB::bind_method(D_METHOD("set_flip_h", "flip_h"), &AnimatedSprite2D::set_flip_h); + ClassDB::bind_method(D_METHOD("is_flipped_h"), &AnimatedSprite2D::is_flipped_h); - ClassDB::bind_method(D_METHOD("set_flip_v", "flip_v"), &AnimatedSprite::set_flip_v); - ClassDB::bind_method(D_METHOD("is_flipped_v"), &AnimatedSprite::is_flipped_v); + ClassDB::bind_method(D_METHOD("set_flip_v", "flip_v"), &AnimatedSprite2D::set_flip_v); + ClassDB::bind_method(D_METHOD("is_flipped_v"), &AnimatedSprite2D::is_flipped_v); - ClassDB::bind_method(D_METHOD("set_frame", "frame"), &AnimatedSprite::set_frame); - ClassDB::bind_method(D_METHOD("get_frame"), &AnimatedSprite::get_frame); + ClassDB::bind_method(D_METHOD("set_frame", "frame"), &AnimatedSprite2D::set_frame); + ClassDB::bind_method(D_METHOD("get_frame"), &AnimatedSprite2D::get_frame); - ClassDB::bind_method(D_METHOD("set_speed_scale", "speed_scale"), &AnimatedSprite::set_speed_scale); - ClassDB::bind_method(D_METHOD("get_speed_scale"), &AnimatedSprite::get_speed_scale); + ClassDB::bind_method(D_METHOD("set_speed_scale", "speed_scale"), &AnimatedSprite2D::set_speed_scale); + ClassDB::bind_method(D_METHOD("get_speed_scale"), &AnimatedSprite2D::get_speed_scale); - ClassDB::bind_method(D_METHOD("set_specular_color", "color"), &AnimatedSprite::set_specular_color); - ClassDB::bind_method(D_METHOD("get_specular_color"), &AnimatedSprite::get_specular_color); + ClassDB::bind_method(D_METHOD("set_specular_color", "color"), &AnimatedSprite2D::set_specular_color); + ClassDB::bind_method(D_METHOD("get_specular_color"), &AnimatedSprite2D::get_specular_color); - ClassDB::bind_method(D_METHOD("set_shininess", "shininess"), &AnimatedSprite::set_shininess); - ClassDB::bind_method(D_METHOD("get_shininess"), &AnimatedSprite::get_shininess); + ClassDB::bind_method(D_METHOD("set_shininess", "shininess"), &AnimatedSprite2D::set_shininess); + ClassDB::bind_method(D_METHOD("get_shininess"), &AnimatedSprite2D::get_shininess); ADD_SIGNAL(MethodInfo("frame_changed")); ADD_SIGNAL(MethodInfo("animation_finished")); @@ -754,7 +754,7 @@ void AnimatedSprite::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_v"), "set_flip_v", "is_flipped_v"); } -AnimatedSprite::AnimatedSprite() { +AnimatedSprite2D::AnimatedSprite2D() { centered = true; hflip = false; diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite_2d.h index e5d015b07c..726ecefd32 100644 --- a/scene/2d/animated_sprite.h +++ b/scene/2d/animated_sprite_2d.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* animated_sprite.h */ +/* animated_sprite_2d.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef ANIMATED_SPRITE_H -#define ANIMATED_SPRITE_H +#ifndef ANIMATED_SPRITE_2D_H +#define ANIMATED_SPRITE_2D_H #include "scene/2d/node_2d.h" #include "scene/resources/texture.h" @@ -140,9 +140,9 @@ public: SpriteFrames(); }; -class AnimatedSprite : public Node2D { +class AnimatedSprite2D : public Node2D { - GDCLASS(AnimatedSprite, Node2D); + GDCLASS(AnimatedSprite2D, Node2D); Ref<SpriteFrames> frames; bool playing; @@ -225,7 +225,7 @@ public: float get_shininess() const; virtual String get_configuration_warning() const; - AnimatedSprite(); + AnimatedSprite2D(); }; #endif // ANIMATED_SPRITE_H diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite_2d.cpp index a6fb6f7435..d45fe9a2a5 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite_2d.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* sprite.cpp */ +/* sprite_2d.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "sprite.h" +#include "sprite_2d.h" #include "core/core_string_names.h" #include "core/os/os.h" @@ -36,49 +36,49 @@ #include "scene/scene_string_names.h" #ifdef TOOLS_ENABLED -Dictionary Sprite::_edit_get_state() const { +Dictionary Sprite2D::_edit_get_state() const { Dictionary state = Node2D::_edit_get_state(); state["offset"] = offset; return state; } -void Sprite::_edit_set_state(const Dictionary &p_state) { +void Sprite2D::_edit_set_state(const Dictionary &p_state) { Node2D::_edit_set_state(p_state); set_offset(p_state["offset"]); } -void Sprite::_edit_set_pivot(const Point2 &p_pivot) { +void Sprite2D::_edit_set_pivot(const Point2 &p_pivot) { set_offset(get_offset() - p_pivot); set_position(get_transform().xform(p_pivot)); } -Point2 Sprite::_edit_get_pivot() const { +Point2 Sprite2D::_edit_get_pivot() const { return Vector2(); } -bool Sprite::_edit_use_pivot() const { +bool Sprite2D::_edit_use_pivot() const { return true; } -bool Sprite::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { +bool Sprite2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { return is_pixel_opaque(p_point); } -Rect2 Sprite::_edit_get_rect() const { +Rect2 Sprite2D::_edit_get_rect() const { return get_rect(); } -bool Sprite::_edit_use_rect() const { +bool Sprite2D::_edit_use_rect() const { return texture.is_valid(); } #endif -Rect2 Sprite::get_anchorable_rect() const { +Rect2 Sprite2D::get_anchorable_rect() const { return get_rect(); } -void Sprite::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_clip) const { +void Sprite2D::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_clip) const { Rect2 base_rect; @@ -112,7 +112,7 @@ void Sprite::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_cli r_dst_rect.size.y = -r_dst_rect.size.y; } -void Sprite::_notification(int p_what) { +void Sprite2D::_notification(int p_what) { switch (p_what) { @@ -137,18 +137,18 @@ void Sprite::_notification(int p_what) { } } -void Sprite::set_texture(const Ref<Texture2D> &p_texture) { +void Sprite2D::set_texture(const Ref<Texture2D> &p_texture) { if (p_texture == texture) return; if (texture.is_valid()) - texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite::_texture_changed)); + texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite2D::_texture_changed)); texture = p_texture; if (texture.is_valid()) - texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite::_texture_changed)); + texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite2D::_texture_changed)); update(); emit_signal("texture_changed"); @@ -156,96 +156,96 @@ void Sprite::set_texture(const Ref<Texture2D> &p_texture) { _change_notify("texture"); } -void Sprite::set_normal_map(const Ref<Texture2D> &p_texture) { +void Sprite2D::set_normal_map(const Ref<Texture2D> &p_texture) { normal_map = p_texture; update(); } -Ref<Texture2D> Sprite::get_normal_map() const { +Ref<Texture2D> Sprite2D::get_normal_map() const { return normal_map; } -void Sprite::set_specular_map(const Ref<Texture2D> &p_texture) { +void Sprite2D::set_specular_map(const Ref<Texture2D> &p_texture) { specular = p_texture; update(); } -Ref<Texture2D> Sprite::get_specular_map() const { +Ref<Texture2D> Sprite2D::get_specular_map() const { return specular; } -void Sprite::set_specular_color(const Color &p_color) { +void Sprite2D::set_specular_color(const Color &p_color) { specular_color = p_color; update(); } -Color Sprite::get_specular_color() const { +Color Sprite2D::get_specular_color() const { return specular_color; } -void Sprite::set_shininess(float p_shininess) { +void Sprite2D::set_shininess(float p_shininess) { shininess = CLAMP(p_shininess, 0.0, 1.0); update(); } -float Sprite::get_shininess() const { +float Sprite2D::get_shininess() const { return shininess; } -Ref<Texture2D> Sprite::get_texture() const { +Ref<Texture2D> Sprite2D::get_texture() const { return texture; } -void Sprite::set_centered(bool p_center) { +void Sprite2D::set_centered(bool p_center) { centered = p_center; update(); item_rect_changed(); } -bool Sprite::is_centered() const { +bool Sprite2D::is_centered() const { return centered; } -void Sprite::set_offset(const Point2 &p_offset) { +void Sprite2D::set_offset(const Point2 &p_offset) { offset = p_offset; update(); item_rect_changed(); _change_notify("offset"); } -Point2 Sprite::get_offset() const { +Point2 Sprite2D::get_offset() const { return offset; } -void Sprite::set_flip_h(bool p_flip) { +void Sprite2D::set_flip_h(bool p_flip) { hflip = p_flip; update(); } -bool Sprite::is_flipped_h() const { +bool Sprite2D::is_flipped_h() const { return hflip; } -void Sprite::set_flip_v(bool p_flip) { +void Sprite2D::set_flip_v(bool p_flip) { vflip = p_flip; update(); } -bool Sprite::is_flipped_v() const { +bool Sprite2D::is_flipped_v() const { return vflip; } -void Sprite::set_region(bool p_region) { +void Sprite2D::set_region(bool p_region) { if (p_region == region) return; @@ -254,12 +254,12 @@ void Sprite::set_region(bool p_region) { update(); } -bool Sprite::is_region() const { +bool Sprite2D::is_region() const { return region; } -void Sprite::set_region_rect(const Rect2 &p_region_rect) { +void Sprite2D::set_region_rect(const Rect2 &p_region_rect) { if (region_rect == p_region_rect) return; @@ -272,21 +272,21 @@ void Sprite::set_region_rect(const Rect2 &p_region_rect) { _change_notify("region_rect"); } -Rect2 Sprite::get_region_rect() const { +Rect2 Sprite2D::get_region_rect() const { return region_rect; } -void Sprite::set_region_filter_clip(bool p_enable) { +void Sprite2D::set_region_filter_clip(bool p_enable) { region_filter_clip = p_enable; update(); } -bool Sprite::is_region_filter_clip_enabled() const { +bool Sprite2D::is_region_filter_clip_enabled() const { return region_filter_clip; } -void Sprite::set_frame(int p_frame) { +void Sprite2D::set_frame(int p_frame) { ERR_FAIL_INDEX(p_frame, vframes * hframes); @@ -300,23 +300,23 @@ void Sprite::set_frame(int p_frame) { emit_signal(SceneStringNames::get_singleton()->frame_changed); } -int Sprite::get_frame() const { +int Sprite2D::get_frame() const { return frame; } -void Sprite::set_frame_coords(const Vector2 &p_coord) { +void Sprite2D::set_frame_coords(const Vector2 &p_coord) { ERR_FAIL_INDEX(int(p_coord.x), hframes); ERR_FAIL_INDEX(int(p_coord.y), vframes); set_frame(int(p_coord.y) * hframes + int(p_coord.x)); } -Vector2 Sprite::get_frame_coords() const { +Vector2 Sprite2D::get_frame_coords() const { return Vector2(frame % hframes, frame / hframes); } -void Sprite::set_vframes(int p_amount) { +void Sprite2D::set_vframes(int p_amount) { ERR_FAIL_COND_MSG(p_amount < 1, "Amount of vframes cannot be smaller than 1."); vframes = p_amount; @@ -324,12 +324,12 @@ void Sprite::set_vframes(int p_amount) { item_rect_changed(); _change_notify(); } -int Sprite::get_vframes() const { +int Sprite2D::get_vframes() const { return vframes; } -void Sprite::set_hframes(int p_amount) { +void Sprite2D::set_hframes(int p_amount) { ERR_FAIL_COND_MSG(p_amount < 1, "Amount of hframes cannot be smaller than 1."); hframes = p_amount; @@ -337,12 +337,12 @@ void Sprite::set_hframes(int p_amount) { item_rect_changed(); _change_notify(); } -int Sprite::get_hframes() const { +int Sprite2D::get_hframes() const { return hframes; } -bool Sprite::is_pixel_opaque(const Point2 &p_point) const { +bool Sprite2D::is_pixel_opaque(const Point2 &p_point) const { if (texture.is_null()) return false; @@ -392,7 +392,7 @@ bool Sprite::is_pixel_opaque(const Point2 &p_point) const { return texture->is_pixel_opaque((int)q.x, (int)q.y); } -Rect2 Sprite::get_rect() const { +Rect2 Sprite2D::get_rect() const { if (texture.is_null()) return Rect2(0, 0, 1, 1); @@ -417,7 +417,7 @@ Rect2 Sprite::get_rect() const { return Rect2(ofs, s); } -void Sprite::_validate_property(PropertyInfo &property) const { +void Sprite2D::_validate_property(PropertyInfo &property) const { if (property.name == "frame") { property.hint = PROPERTY_HINT_RANGE; @@ -430,7 +430,7 @@ void Sprite::_validate_property(PropertyInfo &property) const { } } -void Sprite::_texture_changed() { +void Sprite2D::_texture_changed() { // Changes to the texture need to trigger an update to make // the editor redraw the sprite with the updated texture. @@ -439,59 +439,59 @@ void Sprite::_texture_changed() { } } -void Sprite::_bind_methods() { +void Sprite2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Sprite::set_texture); - ClassDB::bind_method(D_METHOD("get_texture"), &Sprite::get_texture); + ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Sprite2D::set_texture); + ClassDB::bind_method(D_METHOD("get_texture"), &Sprite2D::get_texture); - ClassDB::bind_method(D_METHOD("set_normal_map", "normal_map"), &Sprite::set_normal_map); - ClassDB::bind_method(D_METHOD("get_normal_map"), &Sprite::get_normal_map); + ClassDB::bind_method(D_METHOD("set_normal_map", "normal_map"), &Sprite2D::set_normal_map); + ClassDB::bind_method(D_METHOD("get_normal_map"), &Sprite2D::get_normal_map); - ClassDB::bind_method(D_METHOD("set_specular_map", "specular_map"), &Sprite::set_specular_map); - ClassDB::bind_method(D_METHOD("get_specular_map"), &Sprite::get_specular_map); + ClassDB::bind_method(D_METHOD("set_specular_map", "specular_map"), &Sprite2D::set_specular_map); + ClassDB::bind_method(D_METHOD("get_specular_map"), &Sprite2D::get_specular_map); - ClassDB::bind_method(D_METHOD("set_specular_color", "specular_color"), &Sprite::set_specular_color); - ClassDB::bind_method(D_METHOD("get_specular_color"), &Sprite::get_specular_color); + ClassDB::bind_method(D_METHOD("set_specular_color", "specular_color"), &Sprite2D::set_specular_color); + ClassDB::bind_method(D_METHOD("get_specular_color"), &Sprite2D::get_specular_color); - ClassDB::bind_method(D_METHOD("set_shininess", "shininess"), &Sprite::set_shininess); - ClassDB::bind_method(D_METHOD("get_shininess"), &Sprite::get_shininess); + ClassDB::bind_method(D_METHOD("set_shininess", "shininess"), &Sprite2D::set_shininess); + ClassDB::bind_method(D_METHOD("get_shininess"), &Sprite2D::get_shininess); - ClassDB::bind_method(D_METHOD("set_centered", "centered"), &Sprite::set_centered); - ClassDB::bind_method(D_METHOD("is_centered"), &Sprite::is_centered); + ClassDB::bind_method(D_METHOD("set_centered", "centered"), &Sprite2D::set_centered); + ClassDB::bind_method(D_METHOD("is_centered"), &Sprite2D::is_centered); - ClassDB::bind_method(D_METHOD("set_offset", "offset"), &Sprite::set_offset); - ClassDB::bind_method(D_METHOD("get_offset"), &Sprite::get_offset); + ClassDB::bind_method(D_METHOD("set_offset", "offset"), &Sprite2D::set_offset); + ClassDB::bind_method(D_METHOD("get_offset"), &Sprite2D::get_offset); - ClassDB::bind_method(D_METHOD("set_flip_h", "flip_h"), &Sprite::set_flip_h); - ClassDB::bind_method(D_METHOD("is_flipped_h"), &Sprite::is_flipped_h); + ClassDB::bind_method(D_METHOD("set_flip_h", "flip_h"), &Sprite2D::set_flip_h); + ClassDB::bind_method(D_METHOD("is_flipped_h"), &Sprite2D::is_flipped_h); - ClassDB::bind_method(D_METHOD("set_flip_v", "flip_v"), &Sprite::set_flip_v); - ClassDB::bind_method(D_METHOD("is_flipped_v"), &Sprite::is_flipped_v); + ClassDB::bind_method(D_METHOD("set_flip_v", "flip_v"), &Sprite2D::set_flip_v); + ClassDB::bind_method(D_METHOD("is_flipped_v"), &Sprite2D::is_flipped_v); - ClassDB::bind_method(D_METHOD("set_region", "enabled"), &Sprite::set_region); - ClassDB::bind_method(D_METHOD("is_region"), &Sprite::is_region); + ClassDB::bind_method(D_METHOD("set_region", "enabled"), &Sprite2D::set_region); + ClassDB::bind_method(D_METHOD("is_region"), &Sprite2D::is_region); - ClassDB::bind_method(D_METHOD("is_pixel_opaque", "pos"), &Sprite::is_pixel_opaque); + ClassDB::bind_method(D_METHOD("is_pixel_opaque", "pos"), &Sprite2D::is_pixel_opaque); - ClassDB::bind_method(D_METHOD("set_region_rect", "rect"), &Sprite::set_region_rect); - ClassDB::bind_method(D_METHOD("get_region_rect"), &Sprite::get_region_rect); + ClassDB::bind_method(D_METHOD("set_region_rect", "rect"), &Sprite2D::set_region_rect); + ClassDB::bind_method(D_METHOD("get_region_rect"), &Sprite2D::get_region_rect); - ClassDB::bind_method(D_METHOD("set_region_filter_clip", "enabled"), &Sprite::set_region_filter_clip); - ClassDB::bind_method(D_METHOD("is_region_filter_clip_enabled"), &Sprite::is_region_filter_clip_enabled); + ClassDB::bind_method(D_METHOD("set_region_filter_clip", "enabled"), &Sprite2D::set_region_filter_clip); + ClassDB::bind_method(D_METHOD("is_region_filter_clip_enabled"), &Sprite2D::is_region_filter_clip_enabled); - ClassDB::bind_method(D_METHOD("set_frame", "frame"), &Sprite::set_frame); - ClassDB::bind_method(D_METHOD("get_frame"), &Sprite::get_frame); + ClassDB::bind_method(D_METHOD("set_frame", "frame"), &Sprite2D::set_frame); + ClassDB::bind_method(D_METHOD("get_frame"), &Sprite2D::get_frame); - ClassDB::bind_method(D_METHOD("set_frame_coords", "coords"), &Sprite::set_frame_coords); - ClassDB::bind_method(D_METHOD("get_frame_coords"), &Sprite::get_frame_coords); + ClassDB::bind_method(D_METHOD("set_frame_coords", "coords"), &Sprite2D::set_frame_coords); + ClassDB::bind_method(D_METHOD("get_frame_coords"), &Sprite2D::get_frame_coords); - ClassDB::bind_method(D_METHOD("set_vframes", "vframes"), &Sprite::set_vframes); - ClassDB::bind_method(D_METHOD("get_vframes"), &Sprite::get_vframes); + ClassDB::bind_method(D_METHOD("set_vframes", "vframes"), &Sprite2D::set_vframes); + ClassDB::bind_method(D_METHOD("get_vframes"), &Sprite2D::get_vframes); - ClassDB::bind_method(D_METHOD("set_hframes", "hframes"), &Sprite::set_hframes); - ClassDB::bind_method(D_METHOD("get_hframes"), &Sprite::get_hframes); + ClassDB::bind_method(D_METHOD("set_hframes", "hframes"), &Sprite2D::set_hframes); + ClassDB::bind_method(D_METHOD("get_hframes"), &Sprite2D::get_hframes); - ClassDB::bind_method(D_METHOD("get_rect"), &Sprite::get_rect); + ClassDB::bind_method(D_METHOD("get_rect"), &Sprite2D::get_rect); ADD_SIGNAL(MethodInfo("frame_changed")); ADD_SIGNAL(MethodInfo("texture_changed")); @@ -519,7 +519,7 @@ void Sprite::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "region_filter_clip"), "set_region_filter_clip", "is_region_filter_clip_enabled"); } -Sprite::Sprite() { +Sprite2D::Sprite2D() { centered = true; hflip = false; @@ -535,5 +535,5 @@ Sprite::Sprite() { hframes = 1; } -Sprite::~Sprite() { +Sprite2D::~Sprite2D() { } diff --git a/scene/2d/sprite.h b/scene/2d/sprite_2d.h index a96f023231..599a9e937e 100644 --- a/scene/2d/sprite.h +++ b/scene/2d/sprite_2d.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* sprite.h */ +/* sprite_2d.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,15 +28,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef SPRITE_H -#define SPRITE_H +#ifndef SPRITE_2D_H +#define SPRITE_2D_H #include "scene/2d/node_2d.h" #include "scene/resources/texture.h" -class Sprite : public Node2D { +class Sprite2D : public Node2D { - GDCLASS(Sprite, Node2D); + GDCLASS(Sprite2D, Node2D); Ref<Texture2D> texture; Ref<Texture2D> normal_map; @@ -136,8 +136,8 @@ public: Rect2 get_rect() const; virtual Rect2 get_anchorable_rect() const; - Sprite(); - ~Sprite(); + Sprite2D(); + ~Sprite2D(); }; #endif // SPRITE_H diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp index 65dabb92b1..6c1d7c3749 100644 --- a/scene/2d/visibility_notifier_2d.cpp +++ b/scene/2d/visibility_notifier_2d.cpp @@ -32,7 +32,7 @@ #include "core/engine.h" #include "particles_2d.h" -#include "scene/2d/animated_sprite.h" +#include "scene/2d/animated_sprite_2d.h" #include "scene/2d/physics_body_2d.h" #include "scene/animation/animation_player.h" #include "scene/main/window.h" @@ -205,7 +205,7 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) { } { - AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node); + AnimatedSprite2D *as = Object::cast_to<AnimatedSprite2D>(p_node); if (as) { add = true; } @@ -292,7 +292,7 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) { } if (enabler[ENABLER_PAUSE_ANIMATED_SPRITES]) { - AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node); + AnimatedSprite2D *as = Object::cast_to<AnimatedSprite2D>(p_node); if (as) { |