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/Button_Node2D.gd

26 lines
803 B
GDScript3
Raw Normal View History

2023-02-25 01:04:08 +01:00
extends Button
onready var villain = $"../Villain/AnimatedSprite"
2023-02-25 17:48:13 +01:00
onready var villain_animations = $"../Villain".animations
2023-02-25 17:48:13 +01:00
var etat = false
2023-02-25 17:29:51 +01:00
const texture_pressed = preload("res://Assets/skin_assets/button_normal.png")
const texture_released = preload("res://Assets/skin_assets/button_pressed.png")
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-25 14:02:57 +01:00
func _process(_delta):
2023-02-25 17:29:51 +01:00
if etat:
2023-02-25 18:46:29 +01:00
if villain.animation == villain_animations[-1]:
get_tree().change_scene("res://Scenes/gameover.tscn")
2023-02-25 01:04:08 +01:00
func _on_Button_pressed():
2023-02-25 15:45:57 +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)