SOLVED Pause all but one room?

flyinian

Member
I am trying to implement a pause system into my game. The only time I want the game to pause is when the player is on the main menu room.

I have numerous persistent objects that are initialized on game start.

Could I use instance_deactivate_all(true) and pick and choose which instances don't get deactivated? Could I choose which rooms don't get deactivated?
 

samspade

Member
rooms aren't activated or deactivated per se. You have one room. that room runs. you can use room persistence to keep another room sort of in stasis, but they aren't 'running'.

Persistent objects are 'running' if you don't want a persistent object to 'run' it should be deactivated either with code such as instance deactive or with a check like:

GML:
if (active == false) exit;
The reason 'run' is in quotes is because I don't think it's the best way to really think about how things works.

Instances can be active or inactive (deactivated). Active instances will run the events that run every step (such as the step events, draw events) and trigger other events (such as input events) as required. Deactivated instances will not.

Rooms don't really run code (outside of the room creation code). So rooms being active or not isn't really a thing. You are in a room or you are not in a room.

When you leave a room, all non persistent instances get destroyed. Persistent instances simple 'transfer' to the new room. When you make a room persistence... I'm actually not sure what happens. I never use room persistence.
 

flyinian

Member
If I were to have a single object that creates the instances of all of my persistent objects and deactivate that single object, would this be effective?
 

samspade

Member

flyinian

Member
No. Creating an instance of an object does not tie or connect the two instances together. However, if you used inheritance then you could say:

GML:
instance_deactivate_object(object_id);
And this would deactivate all instances of that object, its children, and their children, and so on.
I'm going to say doing a control variable in each object and setting it to true or false through a persistent control object would be easiest and safest if I wanted to do a pause system(Your first comment). I think I have way to many persistent objects to do a pause system through inheritance.


Thanks for the help.
 

kburkhart84

Firehammer Games
Another thing to consider...there is nothing wrong with deactivating all the instances, and then using the activation functions to re-activate the ones that you want to bring back to life right away. Just because you deactivate or even if you destroy the instance code is running on doesn't mean that the code block you are in doesn't finish out(in fact, the code continues past the line that destroys or deactivates the instance).
 

flyinian

Member
Another thing to consider...there is nothing wrong with deactivating all the instances, and then using the activation functions to re-activate the ones that you want to bring back to life right away. Just because you deactivate or even if you destroy the instance code is running on doesn't mean that the code block you are in doesn't finish out(in fact, the code continues past the line that destroys or deactivates the instance).
Thanks, I wish there was a simple way to deactivate all besides whats in current room. Especially when you have a lot of persistent objects that rely on each other.
 

kburkhart84

Firehammer Games
If you deactivate all, it WILL deactivate whats in the current room. If you make the object persistent, it gets carried over and is therefore IN this room as well once you arrive there. I recommend you take make a parent "controller" object. Leave it empty, and make your controllers all be children of it. Then, you can deactivate all, and right then, activate that parent controller, which will reactivate your controllers. I see no difficulty here.
 

flyinian

Member
If you deactivate all, it WILL deactivate whats in the current room. If you make the object persistent, it gets carried over and is therefore IN this room as well once you arrive there. I recommend you take make a parent "controller" object. Leave it empty, and make your controllers all be children of it. Then, you can deactivate all, and right then, activate that parent controller, which will reactivate your controllers. I see no difficulty here.
Thank you, I'll be doing this.
 

samspade

Member
If you deactivate all, it WILL deactivate whats in the current room. If you make the object persistent, it gets carried over and is therefore IN this room as well once you arrive there. I recommend you take make a parent "controller" object. Leave it empty, and make your controllers all be children of it. Then, you can deactivate all, and right then, activate that parent controller, which will reactivate your controllers. I see no difficulty here.
That is not completely correct. "Note that if you have deactivated an instance or object that has been flagged as Persistent, then you will need to reactivate it again with the function instance_activate_object before changing room, otherwise it will not be carried over and will be discarded instead."
 

kburkhart84

Firehammer Games
I guess it would have been more easily understood if I left the first sentence on one line and then put the rest in a separate paragraph. I was referring to in general instances that were persistent, not after they get deactivated. The OP seemed to think that persistent objects were somehow working in this room even though they weren't actually in this room, and I was clarifying that if they are persistent, then as far as any code is concerned, they are now officially IN this room once you come to this room. It was separate from the deactivation part itself. I gotta read through what I write before hitting that post reply button.
 
Top