Skip to content

Commit

Permalink
Merge pull request godotengine#16756 from willnationsdev/shifted-rect…
Browse files Browse the repository at this point in the history
…-sprite

Simplify detection of Sprite clicks
  • Loading branch information
akien-mga authored Feb 21, 2018
2 parents 4009c01 + b0bdb44 commit 222516a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion scene/2d/sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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"));

Expand Down
4 changes: 3 additions & 1 deletion scene/2d/sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Sprite : public Node2D {
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;
Expand Down Expand Up @@ -110,6 +110,8 @@ class Sprite : public Node2D {
void set_hframes(int p_amount);
int get_hframes() const;

Rect2 get_rect() const;

Sprite();
};

Expand Down

0 comments on commit 222516a

Please sign in to comment.