forgot i stored player and ball scenes inside their spawn markers :p
This commit is contained in:
parent
bc9cb7b455
commit
bcc939df1c
2 changed files with 4 additions and 6 deletions
|
|
@ -11,9 +11,6 @@ class_name Level extends Node2D
|
|||
@export var block_layer: BlockTileLayer
|
||||
#@export var goal_layer: GoalTileLayer
|
||||
|
||||
@onready var player_scene: PackedScene = preload("res://scenes/player/player.tscn")
|
||||
@onready var ball_scene: PackedScene = preload("res://scenes/ball/ball.tscn")
|
||||
|
||||
var player_1: Player
|
||||
var player_2: Player
|
||||
var ball: Ball
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ func _enter(_previous_state_path: String, _data: Dictionary = {"round": 0, "rest
|
|||
|
||||
func _instantiate_player(id: int) -> Player:
|
||||
var s: PlayerSpawnPoint = level.player_1_spawn if id == 1 else level.player_2_spawn
|
||||
var p: Player = level.player_scene.instantiate()
|
||||
var p: Player = s.player_scene.instantiate()
|
||||
|
||||
p.id = id
|
||||
p.name = "Player"+str(id)
|
||||
|
|
@ -54,10 +54,11 @@ func _instantiate_player(id: int) -> Player:
|
|||
|
||||
|
||||
func _instantiate_ball() -> Ball:
|
||||
var b: Ball = level.ball_scene.instantiate()
|
||||
var s: BallSpawnPoint = level.ball_spawn
|
||||
var b: Ball = s.ball_scene.instantiate()
|
||||
|
||||
level.add_child(b)
|
||||
|
||||
b.global_position = level.ball_spawn.global_position
|
||||
b.global_position = s.global_position
|
||||
|
||||
return b
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue