0 votes

When I start game, script work:

func _ready():
    $Play.connect('pressed', self, 'play');
    $Settings.connect('pressed', self, 'settings');
    $Exit.connect('pressed', self, 'exit');

func play():
    get_node('/root/Global').goto_scene("res://levels/1.tscn");

func exit():
    get_tree().quit();

func settings():
    get_node('/root/Global').goto_scene("res://levels/main_menu/settings.tscn");

Global.gd:

var current_scene = null

func _ready():
        var root = get_tree().get_root()
        current_scene = root.get_child(root.get_child_count() -1)

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


func _deferred_goto_scene(path):
    current_scene.free()

    var s = ResourceLoader.load(path)

    current_scene = s.instance()

    get_tree().get_root().add_child(current_scene)

    get_tree().set_current_scene(current_scene)

But when I change the 1.tscn to first scene, buttons not work.

in Engine by (18 points)

1 Answer

0 votes

The buttons not work on pause.Sorry, it my fail

by (18 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.