use new animations in button logic

This commit is contained in:
Mylloon 2023-02-25 17:48:13 +01:00
parent f17a87de2e
commit a576058b01
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 7 additions and 8 deletions

View file

@ -6,6 +6,7 @@ onready var timer
var limit_random
var rng = RandomNumberGenerator.new()
onready var button = $"../Button/"
export(Array, String) var animations = ["orange", "red"]
# True if animation should change
var next = false
@ -23,8 +24,6 @@ func _ready():
func _process(delta):
timer += delta
var animations = ["orange", "red"]
var max_frame = me.frames.get_frame_count(me.animation) - 1
var current_anim_idx = animations.find(me.animation)
if current_anim_idx >= animations.size() - 1:

View file

@ -1,8 +1,9 @@
extends Button
onready var villain = $"../Villain/AnimatedSprite"
onready var villain_animations = $"../Villain".animations
var etat
var etat = false
const texture_pressed = preload("res://Assets/skin_assets/button_normal.png")
const texture_released = preload("res://Assets/skin_assets/button_pressed.png")
@ -10,11 +11,10 @@ const texture_released = preload("res://Assets/skin_assets/button_pressed.png")
# Called every frame. '_delta' is the elapsed time since the previous frame.
func _process(_delta):
if etat:
match villain.get_frame():
2:
print("non")
_:
print("oui")
if villain.animation == villain_animations[1]:
print("non")
else:
print("oui")
else:
print("caché")