diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-03-22 01:46:18 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-03-22 01:46:18 -0300 |
commit | c6c72a3c37a44964ec8e6b3353f78635bf588eab (patch) | |
tree | 07cdc6f2a776dece704cce526cfd15ae04e44360 /demos/2d | |
parent | 40496dd76ae53c93ef5ea7e56671682a7cae9def (diff) |
input events on Area2D is now supported
also added a demo showing how this works
Diffstat (limited to 'demos/2d')
-rw-r--r-- | demos/2d/area_input/box_area.png | bin | 0 -> 1246 bytes | |||
-rw-r--r-- | demos/2d/area_input/circle_area.png | bin | 0 -> 3030 bytes | |||
-rw-r--r-- | demos/2d/area_input/engine.cfg | 4 | ||||
-rw-r--r-- | demos/2d/area_input/input.gd | 20 | ||||
-rw-r--r-- | demos/2d/area_input/input.scn | bin | 0 -> 2886 bytes |
5 files changed, 24 insertions, 0 deletions
diff --git a/demos/2d/area_input/box_area.png b/demos/2d/area_input/box_area.png Binary files differnew file mode 100644 index 0000000000..ba7c37f7de --- /dev/null +++ b/demos/2d/area_input/box_area.png diff --git a/demos/2d/area_input/circle_area.png b/demos/2d/area_input/circle_area.png Binary files differnew file mode 100644 index 0000000000..3cc24c8a0c --- /dev/null +++ b/demos/2d/area_input/circle_area.png diff --git a/demos/2d/area_input/engine.cfg b/demos/2d/area_input/engine.cfg new file mode 100644 index 0000000000..3227e9278f --- /dev/null +++ b/demos/2d/area_input/engine.cfg @@ -0,0 +1,4 @@ +[application] + +name="Area 2D Input Events" +main_scene="res://input.scn" diff --git a/demos/2d/area_input/input.gd b/demos/2d/area_input/input.gd new file mode 100644 index 0000000000..acecd095ed --- /dev/null +++ b/demos/2d/area_input/input.gd @@ -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("") + + + diff --git a/demos/2d/area_input/input.scn b/demos/2d/area_input/input.scn Binary files differnew file mode 100644 index 0000000000..0bb3a18834 --- /dev/null +++ b/demos/2d/area_input/input.scn |