Fix des timer attaque + ajout tableau slot attaque
This commit is contained in:
parent
e9952f4ec9
commit
4040779923
11 changed files with 155 additions and 106 deletions
|
@ -15,14 +15,7 @@ var is_on_cooldown = false # Indique si le cooldown est en cours
|
|||
|
||||
func set_scene_parent(node: Node) -> void:
|
||||
scene_node = node
|
||||
# Si scene_node est défini pour la première fois, on ajoute un Timer
|
||||
if not scene_node.has_node("TirCooldownTimer"):
|
||||
var cooldown_timer = Timer.new()
|
||||
cooldown_timer.name = "TirCooldownTimer"
|
||||
cooldown_timer.one_shot = true
|
||||
cooldown_timer.wait_time = cooldown
|
||||
cooldown_timer.connect("timeout", Callable(self, "_on_cooldown_timeout"))
|
||||
scene_node.add_child(cooldown_timer)
|
||||
|
||||
|
||||
|
||||
func _process(delta) -> void:
|
||||
|
@ -45,16 +38,3 @@ func spawn_balle(player_position: Vector2, direction_balle: Vector2, angle: floa
|
|||
color_index = (1 +color_index)% len(color_list)
|
||||
balle.get_node("Sprite2D").texture = color_list[color_index]
|
||||
scene_node.add_child(balle)
|
||||
# Démarrez le cooldown après ce tir
|
||||
start_cooldown()
|
||||
|
||||
|
||||
# Démarrer le timer pour le cooldown
|
||||
func start_cooldown() -> void:
|
||||
is_on_cooldown = true
|
||||
var cooldown_timer = scene_node.get_node("TirCooldownTimer")
|
||||
cooldown_timer.start()
|
||||
|
||||
|
||||
func _on_cooldown_timeout() -> void:
|
||||
is_on_cooldown = false # Réinitialisez l'état de cooldown après expiration du Timer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue