Button that takes you to different scenes

I’m new to gdevelop, so sorry if the question is too obvious. I’m building an interactive children’s story, in which readers make choices. like a rpg game book. At some point, the same scene in the book, can come back to two different scenes. EX.: Scene 11 has a button, but it can go back to scene 9 or scene 10 if the readers came from scene 9 or scene 10.

Tank you!
[image]

2 Likes

Hi!!! I’m new here too, but your question seems not as complicated as mine, ahah I’ll share my vision of solving this problem, add a global variable and, depending on its value, assign where the transition should be made (well, i.e. to which scene).
p.s. global variables are very useful when it comes to moving data from one scene to another.

1 Like

It reminds me of the “Choose your adventure” books with their “go to page 57 for this or 13 for that”.

As VMakar85 said, you can store details in Global variables depending on the level of interaction and then change the scene and the scene can check the global variable when the scene starts or in connection to other events and make changes should the past actions change the way it’s replayed. The player may now have a key to a locked door or chest.

I love the possibilities. In one scene the player finds a key. You could set a global Boolean named HasKeyToAttic and when you switcth to that scene you could check the value and expand the way the scene plays or add another choice that takes them to a different scene.

Tank you! As I said, I’m in the first steps of Gdevelop
I understand a little of the logic, but I’m having trouble tracing the process step by step

2 Likes

The options are limitless. Here are a few examples.

Edit: You could also use Boolean variable to add buttons or objects that the player can interact with or take the player to another scene.

Scene 9 and scene 10 lead to scene 11. When I click the back button, I need the scene to go back to the origin line.


Like this?

btw i used button extension

I’m not sure what you mean by “origin line”. How are you displaying the text? Are you using text objects in connection to an extension or behavior? Are you trying to move a pointer or other visual cue?

Edit: You can also pause scenes and then go back. I’m not too familaiar with that process.

The events are just examples. Thr current process wouldn’t work, the lines would conflict with each other. It’s just a way to display choices. You would pause 1 scene and then go back from the other.

Here’s a link to the wiki.

Scene - GDevelop documentation

It’s simpler than that. It’s not a game. It’s more like an interactive book. I will put an illustrative image. It’s pretty simple (not for me anyway). I can get to page 11 through pages 9 or 10. I have a back button on page 11. Which should go back to page 9 if you came from page 9. And back to page 10 if you came from page 10


1 Like

It looks beautiful. You can pause the scene and then return afterward.

I’m not sure what you’re using to differentiate between forward and the shared page.This uses a forward and backward sprite. You can make them Globally since they’re identical. I added a button to go to Scene99.

Scene1

Scene2

Scene99

Test online

Source:
doug13579/Change-scene-storybook-style (github.com)

Thank you, i think it worked!

1 Like

Hi
I’ve come to this situation with my confirm exit scene in a game. The user can get to the confirmation scene trhough two diferent scenes. I wanted that when it clicked on “Cancel/No” button it were redirected to the scene were he was.
I’ve used the global variable way. I’ve created a global variable called “LastScene”. At each of the scenes in the “At beginning of the scene” event I’ve put an action changing the value of the global variable, string, to the name of the scene:
LastScene = CurrentSceneName()
At the quit confirmation scene I’ve put an action associated with clicking on the “Cancel/No” button that redirects using the value of “LastScene”:
Change to scene GlobalVariableString(LastScene)
Just another way of solving the problem

2 Likes

Tank you!I will try this way too!