clean up Scene code
This commit is contained in:
parent
04026c9381
commit
f27a3c9b6f
1 changed files with 4 additions and 16 deletions
|
@ -5,31 +5,21 @@ extends Node2D
|
|||
|
||||
@onready var current_scene = $CurrentScene
|
||||
#@onready var scene_transition = $ScreenTransition/AnimationPlayer
|
||||
var next_scene = null
|
||||
|
||||
var player
|
||||
var player_location : Vector2 = Vector2(0,0)
|
||||
var player_direction : float = 1
|
||||
|
||||
|
||||
|
||||
func transition_to_scene(new_scene: PackedScene, spawn_location:Vector2, spawn_direction:float ):
|
||||
next_scene = new_scene
|
||||
player_location = spawn_location
|
||||
player_direction = spawn_direction
|
||||
func transition_to_scene(new_scene: PackedScene, spawn_location = Vector2(0,0), spawn_direction = 1):
|
||||
#screen_transition.play('FadeToBlack')
|
||||
if(current_scene.get_child(0)):
|
||||
current_scene.get_child(0).queue_free()
|
||||
current_scene.add_child(next_scene.instantiate())
|
||||
current_scene.add_child(new_scene.instantiate())
|
||||
|
||||
#region Spawn Player
|
||||
|
||||
if (player):
|
||||
player.teleport(player_location, player_direction)
|
||||
player.teleport(spawn_location, spawn_direction)
|
||||
else:
|
||||
player = $CurrentScene.find_child("player",true)
|
||||
if (player):
|
||||
player.teleport(player_location, player_direction)
|
||||
player.teleport(spawn_location, spawn_direction)
|
||||
else:
|
||||
if (InitialPlayer):
|
||||
player = InitialPlayer.instantiate()
|
||||
|
@ -37,9 +27,7 @@ func transition_to_scene(new_scene: PackedScene, spawn_location:Vector2, spawn_d
|
|||
add_child(player)
|
||||
else:
|
||||
printerr("No Initial player found")
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
func _on_ready():
|
||||
transition_to_scene(InitialMap,Vector2(0,0),1)
|
||||
|
|
Loading…
Reference in a new issue