diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-03-05 22:36:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-05 22:36:05 +0100 |
commit | aaeb07d50fdf9a19beadd8329d71dbae8ea75e40 (patch) | |
tree | 9455db16898bef6099c223b0a90e1d9b8f19165c /doc/classes/Sprite2D.xml | |
parent | f9dad47478bf3a089b34f2e099164a5d4b388ef5 (diff) | |
parent | bae843a1c9dadad2b40e17f1e44e13eb01d65f97 (diff) |
Merge pull request #43929 from HaSa1002/docs-lang-6
Docs: Port Code Examples to C# (R, S, T, U)
Diffstat (limited to 'doc/classes/Sprite2D.xml')
-rw-r--r-- | doc/classes/Sprite2D.xml | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/doc/classes/Sprite2D.xml b/doc/classes/Sprite2D.xml index 83235f0991..e4df753674 100644 --- a/doc/classes/Sprite2D.xml +++ b/doc/classes/Sprite2D.xml @@ -15,12 +15,29 @@ </return> <description> Returns a [Rect2] representing the Sprite2D's boundary in local coordinates. Can be used to detect if the Sprite2D was clicked. Example: - [codeblock] + [codeblocks] + [gdscript] 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] + [/gdscript] + [csharp] + public override void _Input(InputEvent inputEvent) + { + if (inputEvent is InputEventMouseButton inputEventMouse) + { + if (inputEventMouse.Pressed && inputEventMouse.ButtonIndex == (int)ButtonList.Left) + { + if (GetRect().HasPoint(ToLocal(inputEventMouse.Position))) + { + GD.Print("A click!"); + } + } + } + } + [/csharp] + [/codeblocks] </description> </method> <method name="is_pixel_opaque" qualifiers="const"> |