extends TextureButton @export var front_texture: Texture2D # Изображение на лицевой стороне @export var back_texture: Texture2D # Изображение на обратной стороне @export var flip_duration: float = 0.3 # Длительность анимации переворота @onready var timer = $Timer var is_flipped: bool = false var can_click: bool = true # Called when the node enters the scene tree for the first time. func _ready() -> void: texture_normal = back_texture func _on_button_down() -> void: if not can_click: return emit_signal ("tile_clicked", self) flip_tile() func flip_tile(): is_flipped = true can_click = false # Анимация переворота var tween = create_tween() tween.tween_property(self, "scale:x", 0.0, flip_duration/2) tween.tween_callback(_change_texture) tween.tween_property(self, "scale:x", 1.0, flip_duration/2) timer.start() func _change_texture(): texture_normal = front_texture if is_flipped else back_texture func hide_tile(): is_flipped = false var tween = create_tween() tween.tween_property(self, "scale:x", 0.0, flip_duration/2) tween.tween_callback(_change_texture) tween.tween_property(self, "scale:x", 1.0, flip_duration/2) tween.tween_callback(_enable_click) func _enable_click(): can_click = true func _on_timer_timeout() -> void: hide_tile()