diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-02-21 10:42:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-21 10:42:47 +0100 |
commit | 222516a8154f4b0dbe1264315337367b60989c9e (patch) | |
tree | 81cddb770b3f5e1eebdd1df10188be801175ab2e | |
parent | 4009c017241f197a74fa2422bf1435ea56ee0903 (diff) | |
parent | b0bdb4456b3e1cc989dab1c8f23389ec0bdf425d (diff) |
Merge pull request #16756 from willnationsdev/shifted-rect-sprite
Simplify detection of Sprite clicks
-rw-r--r-- | scene/2d/sprite.cpp | 4 | ||||
-rw-r--r-- | scene/2d/sprite.h | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index 17ca066fc0..796969be1e 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -297,7 +297,7 @@ bool Sprite::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc return c.a > 0.01; } -Rect2 Sprite::_edit_get_rect() const { +Rect2 Sprite::get_rect() const { if (texture.is_null()) return Rect2(0, 0, 1, 1); @@ -374,6 +374,8 @@ void Sprite::_bind_methods() { 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("get_rect"), &Sprite::get_rect); + ADD_SIGNAL(MethodInfo("frame_changed")); ADD_SIGNAL(MethodInfo("texture_changed")); diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h index 0422e0635f..dd3719099f 100644 --- a/scene/2d/sprite.h +++ b/scene/2d/sprite.h @@ -72,7 +72,7 @@ public: virtual Point2 _edit_get_pivot() const; virtual bool _edit_use_pivot() const; virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const; - virtual Rect2 _edit_get_rect() const; + virtual Rect2 _edit_get_rect() const { return get_rect(); } void set_texture(const Ref<Texture> &p_texture); Ref<Texture> get_texture() const; @@ -110,6 +110,8 @@ public: void set_hframes(int p_amount); int get_hframes() const; + Rect2 get_rect() const; + Sprite(); }; |