Creating and accessing a dictionary of scenes

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

Hello again!
I’m trying to make a game where I load multiple levels (each level is a scene).
I’ve never done this before, so I thought I could use a dictionary maybe, but I don’t know how to make it work. I’m not quite sure about the syntax too.
Can anyone give me suggestions? Is it a good way to do it/is it viable?

There are plenty of ways to make multi-level games.

You can use get_tree().change_scene() (which will replace the whole current scene by the next one) or have a scene that loads levels as child of itself (so you can re-use parts without having to create singletons).

You can have a look at the Minilens demo game to see how it’s done: GitHub - KOBUGE-Games/minilens: Cute puzzle platformer starring a cleaning robot on post-apocalyptic Earth

Zylann | 2017-05-01 21:40

Thanks, I’ll try messing around :slight_smile:

DodoIta | 2017-05-02 15:18

:bust_in_silhouette: Reply From: brunosxs

A code me and my partner made for godot’s jam some time ago has just this…

On it, I simply made an array that held the path to the tscn in the level order I wanted.

Then, when the player managed to finish a level, the function advance_level() would kick in, and do some statistics saving and if the level the player just beat wasn’t the last in this array, it would go to the next one…

Quite useful, thank you for sharing =)

DodoIta | 2017-05-02 15:18