mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-07 08:20:11 +01:00
input events on Area2D is now supported
also added a demo showing how this works
This commit is contained in:
BIN
2d/area_input/box_area.png
Normal file
BIN
2d/area_input/box_area.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
2d/area_input/circle_area.png
Normal file
BIN
2d/area_input/circle_area.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
4
2d/area_input/engine.cfg
Normal file
4
2d/area_input/engine.cfg
Normal file
@@ -0,0 +1,4 @@
|
||||
[application]
|
||||
|
||||
name="Area 2D Input Events"
|
||||
main_scene="res://input.scn"
|
||||
20
2d/area_input/input.gd
Normal file
20
2d/area_input/input.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
extends Area2D
|
||||
|
||||
# member variables here, example:
|
||||
# var a=2
|
||||
# var b="textvar"
|
||||
|
||||
#virtual from CollisionObject2D (also available as signal)
|
||||
func _input_event(viewport, event, shape_idx):
|
||||
#convert event to local coordinates
|
||||
if (event.type==InputEvent.MOUSE_MOTION):
|
||||
event = make_input_local( event )
|
||||
get_node("label").set_text(str(event.pos))
|
||||
|
||||
#virtual from CollisionObject2D (also available as signal)
|
||||
func _mouse_exit():
|
||||
get_node("label").set_text("")
|
||||
|
||||
|
||||
|
||||
BIN
2d/area_input/input.scn
Normal file
BIN
2d/area_input/input.scn
Normal file
Binary file not shown.
Reference in New Issue
Block a user