preload hit scene on player load instead of per hit
This commit is contained in:
parent
4fd1b4dc17
commit
75b2edc212
2 changed files with 3 additions and 2 deletions
|
|
@ -5,6 +5,7 @@ const DEADZONE: float = 0.1
|
|||
@export var id: int = 1
|
||||
@export var max_speed: float = 90
|
||||
|
||||
@onready var hit_scene: PackedScene = preload("res://scenes/hit/power_hit.tscn")
|
||||
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
@onready var anim_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var state_machine: StateMachine = $StateMachine
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
|||
var hit_node: Hit
|
||||
|
||||
if hit_type == "left" or hit_type == "right":
|
||||
hit_node = preload("res://scenes/hit/small_hit.tscn").instantiate()
|
||||
hit_node = player.hit_scene.instantiate()
|
||||
# flip entire node horizontally if spawning left
|
||||
# flip vertically if player 2
|
||||
hit_node.scale = Vector2(
|
||||
|
|
@ -57,7 +57,7 @@ func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
|||
(sprite_texture.get_height()*-1) if player.id == 1 else 4
|
||||
)
|
||||
elif hit_type == "power":
|
||||
hit_node = preload("res://scenes/hit/power_hit.tscn").instantiate()
|
||||
hit_node = player.hit_scene.instantiate()
|
||||
|
||||
player.add_child(hit_node)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue