input events on Area2D is now supported

also added a demo showing how this works
This commit is contained in:
Juan Linietsky
2015-03-22 01:46:18 -03:00
parent 185b644563
commit 43c9f4921f
5 changed files with 24 additions and 0 deletions

BIN
2d/area_input/box_area.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

4
2d/area_input/engine.cfg Normal file
View File

@@ -0,0 +1,4 @@
[application]
name="Area 2D Input Events"
main_scene="res://input.scn"

20
2d/area_input/input.gd Normal file
View 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

Binary file not shown.