Fixed hanging on color switching
This commit is contained in:
@@ -32,6 +32,7 @@ const PICKUP_OFFSET = 16.0
|
|||||||
|
|
||||||
|
|
||||||
var _is_alive := true
|
var _is_alive := true
|
||||||
|
var _is_switching_needed := false
|
||||||
|
|
||||||
|
|
||||||
@onready var sprite : AnimatedSprite2D = $AnimatedSprite2D
|
@onready var sprite : AnimatedSprite2D = $AnimatedSprite2D
|
||||||
@@ -39,6 +40,7 @@ var _is_alive := true
|
|||||||
@onready var pickups : Node2D = $Pickups
|
@onready var pickups : Node2D = $Pickups
|
||||||
@onready var jump_buffer_timer : Timer = $JumpBufferTimer
|
@onready var jump_buffer_timer : Timer = $JumpBufferTimer
|
||||||
@onready var coyote_time_timer : Timer = $CoyoteTimeTimer
|
@onready var coyote_time_timer : Timer = $CoyoteTimeTimer
|
||||||
|
@onready var center_area : Area2D = $CenterArea2D
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
@@ -79,13 +81,28 @@ func _physics_process(delta: float) -> void:
|
|||||||
|
|
||||||
_update_animation()
|
_update_animation()
|
||||||
|
|
||||||
|
if _is_switching_needed:
|
||||||
|
_switch()
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("switch_color") and _is_alive:
|
if event.is_action_pressed("switch_color"):
|
||||||
|
_switch()
|
||||||
|
|
||||||
|
|
||||||
|
func _switch() -> void:
|
||||||
|
_is_switching_needed = false
|
||||||
|
|
||||||
|
if not _is_alive:
|
||||||
|
return
|
||||||
|
|
||||||
|
if center_area.get_overlapping_bodies().size() == 0:
|
||||||
SoundManager.play_sfx_stream(SoundManager.sfx_stream_switch, global_position)
|
SoundManager.play_sfx_stream(SoundManager.sfx_stream_switch, global_position)
|
||||||
collision_switcher.switch_color()
|
collision_switcher.switch_color()
|
||||||
|
else:
|
||||||
|
_is_switching_needed = true
|
||||||
|
|
||||||
|
|
||||||
func kill() -> void:
|
func kill() -> void:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ radius = 4.0
|
|||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_t6gq4"]
|
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_t6gq4"]
|
||||||
radius = 2.0
|
radius = 2.0
|
||||||
height = 15.0
|
height = 10.0
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody2D" unique_id=508706417]
|
[node name="Player" type="CharacterBody2D" unique_id=508706417]
|
||||||
collision_layer = 128
|
collision_layer = 128
|
||||||
@@ -42,6 +42,8 @@ wait_time = 0.1
|
|||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
[node name="CenterArea2D" type="Area2D" parent="." unique_id=490866430]
|
[node name="CenterArea2D" type="Area2D" parent="." unique_id=490866430]
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 35
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CenterArea2D" unique_id=1350886064]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="CenterArea2D" unique_id=1350886064]
|
||||||
shape = SubResource("CapsuleShape2D_t6gq4")
|
shape = SubResource("CapsuleShape2D_t6gq4")
|
||||||
|
|||||||
Reference in New Issue
Block a user