Button to call new window

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By NowakSotto
:warning: Old Version Published before Godot 3 was released.

Hello,

i think i understand but to solve my thoughts.

A new window = new scene ?

So to call a new windows when i click in a button i can use:

var scene = load(“res://myscene.scn”)

this code and all the implements of it ??

:bust_in_silhouette: Reply From: Bishop

yes…almost,yes…that’s it :slight_smile:

extends Node


var current_scene = null

func _ready():
	set_process_input(true)
	set_process(true)
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED);

func goto_scene(path):
	call_deferred("_deferred_goto_scene",path)


# Load scene
func _input(event):
	if(Input.is_action_pressed("scene1")):
		get_tree().change_scene("res://scenes/scene1.scn")
	if (Input.is_action_pressed("scene2")):
		get_tree().change_scene("res://scenes/scene2.scn")

func _deferred_goto_scene(path):
	current_scene.free()

thanks man :).

NowakSotto | 2017-05-18 20:48

func _on_Botao_Start_pressed():
get_tree().change_scene("res://Tela Monster.tscn")

I make this way, its correct too ?

NowakSotto | 2017-05-18 20:52

Yes, but don’t forget free current scene

Bishop | 2017-05-18 21:23

func _deferred_goto_scene(path):
current_scene("res://MonsterCare.tscn").free()

this way ?

sorry im new on godot script

NowakSotto | 2017-05-19 14:15

It would work as follows

yet…i’m too GDscript greenhorn :slight_smile:

extends Control

var current_scene = null

func _ready():
	set_process(true)


func goto_scene(path):
    call_deferred("_deferred_goto_scene",path)

func _on_Botao_Start_pressed():
	get_tree().change_scene("res://Tela Monster.tscn")

func _on_MonsterCare_pressed():
       get_tree().change_scene("res://MonsterCare.tscn")

func _deferred_goto_scene(path):
    current_scene.free()

Bishop | 2017-05-23 13:55