call point light method instead of manually enabling it
This commit is contained in:
parent
bd6ced2a16
commit
0463707616
3 changed files with 10 additions and 6 deletions
|
|
@ -10,7 +10,7 @@ const DEADZONE = 0.1
|
|||
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
@onready var state_machine: StateMachine = $PlayerStateMachine
|
||||
@onready var point_light: PointLight2D = $PointLight2D
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var point_light_animation: AnimationPlayer = $PointLight2D/AnimationPlayer
|
||||
|
||||
var h_press_tick: int = 0 ## last time horizontal axis was pressed
|
||||
var v_press_tick: int = 0 ## last time vertical axis was pressed
|
||||
|
|
@ -84,7 +84,7 @@ func _on_loop_toggled(enabled: bool, loop_size: Rect2i) -> void:
|
|||
func enable_point_light(enabled: bool, energy: float = 0) -> void:
|
||||
point_light.enabled = enabled
|
||||
point_light.energy = energy
|
||||
if enabled: animation_player.play("default")
|
||||
else: animation_player.pause()
|
||||
if enabled: point_light_animation.play("default")
|
||||
else: point_light_animation.play("RESET")
|
||||
|
||||
point_light_toggled.emit(enabled, energy)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ tracks/0/keys = {
|
|||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [0.0]
|
||||
"values": [-15.0]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_qek5x"]
|
||||
|
|
@ -72,8 +72,10 @@ metadata/_custom_type_script = "uid://bebe1y51hwns8"
|
|||
enabled = false
|
||||
energy = 0.0
|
||||
texture = ExtResource("5_75vfm")
|
||||
offset = Vector2(0, -15)
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="PointLight2D"]
|
||||
root_node = NodePath("../..")
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_qek5x")
|
||||
}
|
||||
|
|
@ -87,3 +89,5 @@ animation = &"idle"
|
|||
position = Vector2(0, -7)
|
||||
shape = SubResource("CapsuleShape2D_gmlin")
|
||||
debug_color = Color(0.28459275, 0.61933166, 0.3529686, 0.41960785)
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
|||
else:
|
||||
player_light_tween.tween_property(room.player.point_light, "energy", 0, room.config.transition_in_duration).set_trans(room.config.transition_in_type).set_ease(Tween.EASE_OUT)
|
||||
player_light_tween.tween_callback(func() -> void:
|
||||
room.player.point_light.enabled = false
|
||||
room.player.enable_point_light(false)
|
||||
player_light_tween = null
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue