This repository has been archived on 2023-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
Boups/Scenes/Scripts/Button_Node2D.gd

32 lines
990 B
GDScript3
Raw Normal View History

2023-02-25 01:04:08 +01:00
extends Button
2023-02-26 18:31:57 +01:00
onready var villain = $"../../../Villain/AnimatedSprite"
onready var villain_animations = $"../../../Villain"
2023-02-26 19:09:57 +01:00
export(bool) var etat = false
const texture_pressed = preload("res://Assets/tres_button/hover-pressed.png")
const texture_released = preload("res://Assets/tres_button/normal.png")
2023-02-25 01:04:08 +01:00
2023-02-26 20:37:46 +01:00
var timer = 0
2023-02-25 01:04:08 +01:00
2023-02-25 17:48:02 +01:00
# Called every frame. '_delta' is the elapsed time since the previous frame.
2023-02-26 20:37:46 +01:00
func _process(delta) -> void:
2023-02-26 17:39:03 +01:00
if etat:
2023-02-26 20:37:46 +01:00
timer += delta
2023-02-26 17:39:03 +01:00
if villain.animation == villain_animations.animations[-1]:
2023-02-26 20:50:11 +01:00
get_tree().change_scene("res://Scenes/gameover.tscn")
2023-02-26 20:37:46 +01:00
if timer >= 7: # fermer le dossier et enlever l'icone
2023-02-26 17:39:03 +01:00
etat = false
self.get_parent().get_parent().visible = false
2023-02-25 01:04:08 +01:00
func _on_Button_pressed() -> void:
2023-02-26 17:39:03 +01:00
etat = !etat
var new_stylebox_normal = self.get_stylebox("normal").duplicate()
if etat:
new_stylebox_normal.texture = texture_pressed
else:
new_stylebox_normal.texture = texture_released
self.add_stylebox_override("normal", new_stylebox_normal)