Close all scenes

Status
Not open for further replies.

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
Lets say your in Scene A and you do Scene.push(SceneB) and in Scene B you hit escape. How would you pop SceneA and B off the stack? 

In Scene B you can do Scene.pop() but that wont clear Scene A.

If this is not possible how do you reload Scene A after Scene B has been popped? Situation for this is that:

In Scene A, you have a selectable window, you scroll up and down and the right hand side window updates. This works because in scroll down and up I call TheWindowObject.refresh().

How ever it seems that once I hit enter to enter into Scene B and then escape to go back in to Scene A, scrolling up and down doesn't update the right hand side window any more. even though the refresh method is being called.

How do you pop all scenes when you pop one or How do you reload the scene you came from when you pop the one you are in 
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
When you call SceneManager's pop funciton, it will set the _scene variable to that of the last value in the scene stack. SceneManager also handles the main loo of the game, requesting that each time the browser window is refreshed, SceneManager's update function is called. In that update function, there is a function to check if the scene is changing, depending on whether or not there is a value to _nextScene, or _exiting is set, in which case the game is to close.

If the _nextScene variable is set, then the previously loaded scene's terminate function is called. On the next update, the new scene will be prepared and then updated until no longer needed.

If you want to clear multiple scenes from the stack, and you know specifically how many you wish to remove, you could directly access the stack with SceneManager._stack, and splice the number you wish to remove. Be sure not to leave the stack empty, though, or the nex time the stack gets popped, it'll crash since you can't create anything out of Null.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
What happens if you do two return_scene commands in a row?


Or in Scene A, before calling Scene B, do a return_scene to get Scene A off the stack?
 

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
When you call SceneManager's pop funciton, it will set the _scene variable to that of the last value in the scene stack. SceneManager also handles the main loo of the game, requesting that each time the browser window is refreshed, SceneManager's update function is called. In that update function, there is a function to check if the scene is changing, depending on whether or not there is a value to _nextScene, or _exiting is set, in which case the game is to close.

If the _nextScene variable is set, then the previously loaded scene's terminate function is called. On the next update, the new scene will be prepared and then updated until no longer needed.

If you want to clear multiple scenes from the stack, and you know specifically how many you wish to remove, you could directly access the stack with SceneManager._stack, and splice the number you wish to remove. Be sure not to leave the stack empty, though, or the nex time the stack gets popped, it'll crash since you can't create anything out of Null.
this makes a lot of sense. thanks

@Zalerinian

Do you know if when I call this.pop() if the preceding scene does a refresh? or if that scenes object, such as windows, sprites or what not do a refresh? Because I don't want to kick you right out back to the menu if you go six scenes in  to something.
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
If you call pop, consecutively in each nested scene, they will each be rebuilt and updated. Scenes in the stack don't retain their data, the stack is just a list of classes that were called, so if you wanted to go backwards through each scene and do something with the data, you can't do that by default. However, if you just want to do something like dispose of sprites and other data, you'd alias the terminate function and put that in there. That will be called whenever the scene is changed, whether it be to go back a scene, or because a new one is pushed to the stack.
 

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
So how bad design would it be if you went Menu -> Scene A -> Scene B -> esc -> Menu ??
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
Well, there's always the idea that we should kinda just try to follow stand ways of doing things, but if you have a good reason and your plugin won't really work otherwise, I'd say do it. There are times when stepping outside that which is normal is necessary for us to do what we need. If you can't get it to work in another way, and you feel that the design is worth it, go for it. If we don't like it in the end, well whoops. People have opinions, not much you can do about that.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,018
Messages
1,018,357
Members
137,803
Latest member
andrewcole
Top