use new animations in button logic
This commit is contained in:
parent
f17a87de2e
commit
a576058b01
2 changed files with 7 additions and 8 deletions
|
@ -6,6 +6,7 @@ onready var timer
|
||||||
var limit_random
|
var limit_random
|
||||||
var rng = RandomNumberGenerator.new()
|
var rng = RandomNumberGenerator.new()
|
||||||
onready var button = $"../Button/"
|
onready var button = $"../Button/"
|
||||||
|
export(Array, String) var animations = ["orange", "red"]
|
||||||
|
|
||||||
# True if animation should change
|
# True if animation should change
|
||||||
var next = false
|
var next = false
|
||||||
|
@ -23,8 +24,6 @@ func _ready():
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
timer += delta
|
timer += delta
|
||||||
|
|
||||||
var animations = ["orange", "red"]
|
|
||||||
|
|
||||||
var max_frame = me.frames.get_frame_count(me.animation) - 1
|
var max_frame = me.frames.get_frame_count(me.animation) - 1
|
||||||
var current_anim_idx = animations.find(me.animation)
|
var current_anim_idx = animations.find(me.animation)
|
||||||
if current_anim_idx >= animations.size() - 1:
|
if current_anim_idx >= animations.size() - 1:
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
extends Button
|
extends Button
|
||||||
|
|
||||||
onready var villain = $"../Villain/AnimatedSprite"
|
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_pressed = preload("res://Assets/skin_assets/button_normal.png")
|
||||||
const texture_released = preload("res://Assets/skin_assets/button_pressed.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.
|
# Called every frame. '_delta' is the elapsed time since the previous frame.
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if etat:
|
if etat:
|
||||||
match villain.get_frame():
|
if villain.animation == villain_animations[1]:
|
||||||
2:
|
print("non")
|
||||||
print("non")
|
else:
|
||||||
_:
|
print("oui")
|
||||||
print("oui")
|
|
||||||
else:
|
else:
|
||||||
print("caché")
|
print("caché")
|
||||||
|
|
||||||
|
|
Reference in a new issue