godot-webrtc-mplayer-testing/global.gd
2021-11-17 16:24:00 -06:00

36 lines
776 B
GDScript

extends Node
const MultiplayerClient = preload("multiplayer_client.gd")
onready var client = MultiplayerClient.new()
func _ready():
# client.signaller.connect("websocket_connected", self, "signaller_disconnected")
add_child(client)
client.signaller.connect("websocket_connected", self, "_signaller_connected")
func goto_scene(scene_resource_name):
var _result = get_tree().change_scene("res://%s.tscn" % scene_resource_name)
func main_menu():
client.close()
goto_scene("main")
func start_singleplayer_game():
client.close()
goto_scene("game")
func _signaller_connected():
goto_scene("multiplayer")
func lobby_browser():
client.close()
Global.client.connect_to_signaller()
func lobby():
goto_scene("lobby")
func quit():
client.close()
get_tree().quit()