Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scene Switcher Tutorial may be outdated #778

Closed
ghost opened this issue Oct 10, 2014 · 6 comments
Closed

Scene Switcher Tutorial may be outdated #778

ghost opened this issue Oct 10, 2014 · 6 comments

Comments

@ghost
Copy link

ghost commented Oct 10, 2014

Followed the Scene Switcher tutorial instructions exactly (no typos).

After saving the three scripts I then hit play and clicked the button. The program failed with the following error: Invalid Call. Unexisting function 'remove' in base 'Viewport'.

I tried replacing the line

get_scene().get_root().remove(current_scene) with get_scene().get_root().remove_node(current_scene) but encountered the same error.

@TheoXD
Copy link
Contributor

TheoXD commented Oct 11, 2014

It's probably a typo. Use remove_child() instead

@ghost
Copy link
Author

ghost commented Oct 12, 2014

Thanks Theo. that gets me one step closer. It now throws the error:

Invalid call. Unexisting function 'current_scene' in base 'Node (global.gd)'.

remove_child() requires an argument but I'm not quite sure what to place there.

Pasting my code here in the hopes that someone can point out where things have gone wrong:

extends Node

var current_scene = null

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

func goto_scene(scene):
    # remove current scene from root and enqueue it for deletion
    get_scene().get_root().remove_child(current_scene)
    current_scene().queue_free()

    # load and add new scene to root
    var s = ResourceLoader.load(scene)
    current_scene = s.instance()
    get_scene().get_root().add_child(current_scene)

@TheoXD
Copy link
Contributor

TheoXD commented Oct 12, 2014

current_scene is an object, not a function, remove () at the end

@ghost
Copy link
Author

ghost commented Oct 12, 2014

Thanks again Theo, silly mistake on my part. Still have a problem though, as clicking the button results in the program being terminated with the dialog Process being debugged exited.

@ghost
Copy link
Author

ghost commented Oct 13, 2014

For any similarly confused newbies that come across this:

Seems like it was the get_scene().get_root().remove_child(current_scene) line that was causing problems. I got rid of that line and reorganised the global.gd script to match the autoload example provided here.

Seems to work okay now, though I'm not sure if pulling remove_child will lead to any hidden ill effects.

@ghost
Copy link
Author

ghost commented Nov 17, 2014

Issue closed.

@ghost ghost closed this as completed Nov 17, 2014
hungrymonkey pushed a commit to jcalifornia/godot that referenced this issue Nov 27, 2017
* Make noncopyable constructor and destructor default

C++11 provides the functionality.
Defining empty functions cause all classes derived from noncopyable
to be non-trivially constructible and non-trivially destructible.

For example, matrix with compile-time layout by definition does not
require an explicit destructor and should be trivially destructible
; however, deriving from noncopyable makes it non-trivially
destrutible. This also affects vector<T, 2> and vector<T, 3>.

* Delete array2d copy constructor and assignment operators
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant