make player instantiating a method
This commit is contained in:
parent
ffd6603eba
commit
6417f384d3
1 changed files with 10 additions and 3 deletions
|
|
@ -3,10 +3,17 @@ extends RoomState
|
||||||
|
|
||||||
func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
||||||
print("entering room")
|
print("entering room")
|
||||||
room.player = room.player_scene.instantiate()
|
room.player = _instantiate_player()
|
||||||
room.add_child(room.player)
|
assert(room.player != null, "player is null")
|
||||||
room.player.global_position = room.initial_spawn
|
|
||||||
room.camera.global_position = room.config.camera_position
|
room.camera.global_position = room.config.camera_position
|
||||||
|
|
||||||
finished.emit(PLAYING)
|
finished.emit(PLAYING)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
func _instantiate_player() -> Player:
|
||||||
|
var p: Player = room.player_scene.instantiate()
|
||||||
|
room.add_child(p)
|
||||||
|
p.global_position = room.initial_spawn
|
||||||
|
|
||||||
|
return p
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue