Godot Version
v4.4.1.stable.official [49a5bc7b6]
Question
When I hover over a Sprite2D with an arrow texture with an Area2D, it should become gray and move ~6 pixels, but instead it does nothing. If I disconnect the “mouse_exited” CollisionObject2D’s signal, appear tween animation is playing fine. I guess both signals fire in the same time, but they shouldn`t. Is it a bug, or am I doing something wrong?
Code: (every arrow extends Move_Tile class)
class_name Move_Tile extends Sprite2D
signal move_tile_clicked()
@export_group("View")
@export var hitbox: Area2D
@export var direction: Vector2i
@export var timer: Timer
var time: float = 0.25
#var is_tween: bool = false
func _ready() -> void:
timer.set_wait_time(time)
hitbox.visible = true
hitbox.input_event.connect(on_move_tile_input)
hitbox.mouse_entered.connect(on_mouse_entered)
hitbox.mouse_entered.connect(on_mouse_exited)
func on_move_tile_input(_viewport: Node, event: InputEvent, _shape_idx: int):
if event.is_action_pressed("click"):
move_tile_clicked.emit(direction)
func on_mouse_entered():
print("mouse entered")
#if not is_tween:
appear()
func on_mouse_exited():
print("mouse exited")
#if not is_tween:
disappear()
func appear():
#is_tween = true
var tween := get_tree().create_tween()
tween.set_trans(Tween.TRANS_SINE)
tween.set_parallel(true)
tween.tween_property(self, "position", Vector2(
position[0] + Globals.cell_size[0]*direction[0]*0.1,
position[1] + Globals.cell_size[1]*direction[1]*0.1), time)
tween.tween_property(self, "modulate", Color(0.7, 0.7, 0.7), time)
#await tween.finished
#is_tween = false
func disappear():
#is_tween = true
var tween := get_tree().create_tween()
tween.set_trans(Tween.TRANS_SINE)
tween.set_parallel(true)
tween.tween_property(self, "position", Vector2(
Globals.cell_size[0]*direction[0],
Globals.cell_size[1]*direction[1]), time)
tween.tween_property(self, "modulate", Color.WHITE, time)
#await tween.finished
#is_tween = false
Scene tree:
Area2D has collisionshape2D or collisionpolygon2D.