Make background same for all levels after user picks one

I am new to GDevelop. I am trying to make simple game for my kids to practice their spelling words. I want my kids to pick the background. Then I want their choice to be the background for each of the following scenes(10 scenes). I have included a screenshot. I don’t know how to get their choice to go to the next scene.

1 Like

:open_mouth:

Here’s the solution:

Upon the user making the choice of background, you want the name of the background object they chose to be stored in a Global Variable. Global Variables are relatable to the whole game rather than just the current scene. Name one “BG” or whatever you desire. When a background is set, Store it’s name in the global variable

Then, upon moving to another scene, you should create an event at the beginning that starts with this condition:
“At the beginning of the scene”

Then, in actions, add this:

Create object “GlobalVariableString(BG)” and there you have it :slight_smile:
Good luck on this program!

(Note: make sure those background objects also exist in the new scene)

No, that won’t work, but it’s along the right lines. Create object requires the object reference, not a string.


@DesignerMoo, firstly, don’t make a copy of your backgrounds in each scene. Making them global objects is a much better way, and they’ll be available in all your scenes. Also, this way means any changes you make to a global object will be reflected in all the scenes (so you don’t have to make the change to every copy in every scene) :


Secondly, to create the background images by name in different scenes, you’ll need to use a global object group :

  1. In the editor, open the Object Groups panel and click on Add a new group and call it BackgroundGroup :
    image

  2. Make the group global - click the 3 vertical dots of the new group, and select Set as global group. This will ensure it’s available for all scenes.

  3. Edit the Background group (double click it or select from the 3 vertical dots), and add all the background objects to it.

  4. Where @Blahooga wrote to use Create object, use the Create an object from its name action (search for “create an obj” to get the action) :
    image
    to get

2 Likes

Ah, I use global objects a lot yet I still forget about it in writing.

Ooh! I never knew “create object from its name” existed. The more you know I guess.

I think just like with functions and other certain actions, Create Object and Create Object from its Name should be unified

Thanks for your help. I made all my backgrounds global objects. I created the BackgroundGroup and made it global also. I added all my backgrounds to my group. Do I have to do any of the beginning part Blahooga was talking about? Where he said to store the name in a global variable?

Yes. the only correction to @Blahooga’s instructions is the create command. You’ll still need to store the name in a global variable so it can be picked up in the other scenes, and have an event in each scene that has the At the beginning of the scene condition, and the Create an object from name action.

Sorry I am asking so many questions. I have attached other screenshots to help fix what I am doing wrong?


Is it ok that I have the background to be on the base layer and the others objects on a different layer?


First word level event sheet

I would use a meaningful name for the global variable, say like ChosenBGName. You enter “Kirby1” as the default value on the right hand side.


Yes, that is a good way of doing it. Just make sure the background layer is below the Word layer in the Layer List. GDevelop draws the objects on layers from the bottom layer in the list, to the top