Add respawn signal from Player connecting to BackgroundParticles
This commit is contained in:
parent
32977ba666
commit
86464d6410
4 changed files with 9 additions and 3 deletions
|
|
@ -45,4 +45,5 @@ offset_right = 5000.0
|
||||||
offset_bottom = 5000.0
|
offset_bottom = 5000.0
|
||||||
|
|
||||||
[connection signal="input_event" from="." to="BackgroundParticles" method="_on_player_input_event"]
|
[connection signal="input_event" from="." to="BackgroundParticles" method="_on_player_input_event"]
|
||||||
|
[connection signal="player_respawned" from="." to="BackgroundParticles" method="_on_player_player_respawned"]
|
||||||
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
|
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,4 @@ extends Node2D
|
||||||
var startPosX : int = 24
|
var startPosX : int = 24
|
||||||
var startPosY : int = 184
|
var startPosY : int = 184
|
||||||
|
|
||||||
var next_level : String = "res://Scenes/main.tscn"
|
var next_level : String = "res://Scenes/Levels/level_4.tscn"
|
||||||
|
|
|
||||||
|
|
@ -63,3 +63,7 @@ func reloadParticles() -> void:
|
||||||
|
|
||||||
#Set the material of the particle child object to the created material.
|
#Set the material of the particle child object to the created material.
|
||||||
particle_child.process_material = material
|
particle_child.process_material = material
|
||||||
|
|
||||||
|
|
||||||
|
func _on_player_player_respawned() -> void:
|
||||||
|
reloadParticles()
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ var move_input : float
|
||||||
var dead : bool
|
var dead : bool
|
||||||
var tile_map_custom_data = []
|
var tile_map_custom_data = []
|
||||||
|
|
||||||
signal player_died
|
signal player_respawned
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
|
||||||
|
|
@ -94,7 +94,6 @@ func death(fallen: bool) -> void:
|
||||||
|
|
||||||
#Prevents movement.
|
#Prevents movement.
|
||||||
dead = true
|
dead = true
|
||||||
player_died.emit()
|
|
||||||
|
|
||||||
#Checks if the player has not fallen out of bounds.
|
#Checks if the player has not fallen out of bounds.
|
||||||
#If not, halt all current velocity, and shrink them down to 0 scale as a death animation.
|
#If not, halt all current velocity, and shrink them down to 0 scale as a death animation.
|
||||||
|
|
@ -122,6 +121,8 @@ func respawn() -> void:
|
||||||
#Sets the Y gravity back to default (downwards)
|
#Sets the Y gravity back to default (downwards)
|
||||||
if al_globals.y_gravity < 0:
|
if al_globals.y_gravity < 0:
|
||||||
al_globals.y_gravity *= -1
|
al_globals.y_gravity *= -1
|
||||||
|
|
||||||
|
player_respawned.emit()
|
||||||
|
|
||||||
#Change their position to the start position of the current level.
|
#Change their position to the start position of the current level.
|
||||||
position.x = current_level.startPosX
|
position.x = current_level.startPosX
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue