From 320b361e162d704781d8739ac7299e7e9ea19cc7 Mon Sep 17 00:00:00 2001 From: Tomasz Chabora Date: Sun, 26 May 2019 15:51:27 +0200 Subject: [PATCH] Add example usage for get_rect() (cherry picked from commit fbf4135fc1e8d0fe44846d617440dee1517a1830) --- doc/classes/Sprite.xml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/classes/Sprite.xml b/doc/classes/Sprite.xml index eff675145f3..c75f4160dfc 100644 --- a/doc/classes/Sprite.xml +++ b/doc/classes/Sprite.xml @@ -13,7 +13,13 @@ - Returns a Rect2 representing the Sprite's boundary relative to its local coordinates. + Returns a [Rect2] representing the Sprite's boundary in local coordinates. Can be used to detect if the Sprite was clicked. Example: + [codeblock] + func _input(event): + if event is InputEventMouseButton and event.pressed and event.button_index == BUTTON_LEFT: + if get_rect().has_point(to_local(event.position)): + print("A click!") + [/codeblock] @@ -48,7 +54,7 @@ The texture's drawing offset. - If [code]true[/code], texture is cut from a larger atlas texture. See [code]region_rect[/code]. Default value: [code]false[/code]. + If [code]true[/code], texture is cut from a larger atlas texture. See [member region_rect]. Default value: [code]false[/code]. If [code]true[/code], the outermost pixels get blurred out.