How can I check that the touch is active within the Area?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By saladass
:warning: Old Version Published before Godot 3 was released.

I making the touch controls, and I need that when the touch enters the area (Area2D for example) or being pressed in the area, then the variable is set to true. And when the touch leaves the area or being released, it is set to false. How can i do that? Thanks in advance!

I tried this, but it doesn’t work when touch enters or leaves the area, it works only when touch being pressed or released within the area:

func _on_Area2D_input_event( viewport, event, shape_idx ):
if event.type == InputEvent.SCREEN_TOUCH:
	if event.is_pressed():
		print("Touch inside the area")
	else:
		print("Touch outside the area")

Probably OK, the examples have validation on Area2D github
Does not work with CanvasLayer

Jond | 2017-11-07 10:54