How to find touch , drag and released proper way on Area2D node with sprite?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Niranjan
func _process(delta):
  if dragging:
	var size = player.allCards.size()
	if CONFIG.turnToPlay.pName == "Me" and size == 7:
		if get_global_mouse_position().y > 232 and get_global_mouse_position().y < 307:
			position = get_global_mouse_position()
			rotation_degrees = 0
			notCardTake = true
			if position.y > 290:
				notCardTake = false
				emit_signal("taked_a_card", self)
		if get_global_mouse_position().y > 410:
			on_set_pickable(player, self)
			position.x = get_global_mouse_position().x
	if CONFIG.turnToPlay.pName == "Me" and size == 8:
		if get_global_mouse_position().y > 445:
			var diffY = abs(get_global_mouse_position().y - y)
			var diffX = abs(get_global_mouse_position().x - x)
			on_set_pickable(player, self)
			if diffX > diffY:
				position.x = get_global_mouse_position().x
			if diffY > diffX:
				position.y = get_global_mouse_position().y
				if get_global_mouse_position().y < 452:
					player.call_deferred("throw_a_card", self)
	if CONFIG.turnToPlay.pName != "Me" and size == 7:
		if get_global_mouse_position().y > 410:
			on_set_pickable(player, self)
			position.x = get_global_mouse_position().x

func _input_event(viewport, event, shape_idx):
   if event is InputEventScreenTouch:
	if event.pressed:
		dragging = true
		x = event.position.x
		y = event.position.y
		initPosition = position
		initAngle = rotation_degrees
		notCardTake = false
		if player:
			self.set_z_index(25+player.allCards.size())
		print("Touch")
		self.get_tree().set_input_as_handled()
	else:
		dragging = false
		if notCardTake:
			position = initPosition
			rotation_degrees = initAngle
		do_arrange()
		print("Released")
		self.get_tree().set_input_as_handled()