• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Rooms and objects

U

User

Guest
I have 3 rooms and 3 objects.
Rooms - room_1, room_2, room_3.
Objects - background_image, logo_image,surface_draw_enable_object.
I want to have one camera and view settings for all rooms.
I want to see background image, logo_image in room_1 and room_2. Not in room 3.

So i must do the same actions for every room?
Like
(room_1 persistent) RoomCreationCode
Code:
create_main_settings_array();
application_surface_draw_enable(false);
surface_resize(application_surface, display_width, display_height);
set_camera_position_and_resolution();
set_main_objects_position();
set_sprites_and_depth_to_all_objects();
room_goto(room_2);
Ok i use my scripts, set camera position, set sprite to my background_image and logo_image.
Everything looks good.

But now i leave room_1 and go to room_2. And all objects (instances) will be destroyed.
My camera position, objects sprites index etc.
So i need to copy this code to (room_2) RoomCreationCode?
It works but, do i really need to copy this code to all rooms?
"New room = new instances=new rules?"
So i need more scripts?
 
S

Silver_Mantis

Guest
It sounds like your objects are not persistent. Make sure you check the little tick box in your object options. They won't be destroyed if they are persistent.
 
U

User

Guest
It sounds like your objects are not persistent. Make sure you check the little tick box in your object options. They won't be destroyed if they are persistent.
You're right.
I completely forgot where it's done, but now everything has been fixed.

But what about code? I need code
Code:
application_surface_draw_enable(false);
surface_resize(application_surface, display_width, display_height);
In my all rooms. In all rooms i want to have the same camera and view settings.
So i can paste code in my room or create script.

But i must use code/script/scripts in all rooms. ctrl+c many times.
Is there any way to create "persistent code"?
 
S

Silver_Mantis

Guest
You're right.
I completely forgot where it's done, but now everything has been fixed.

But what about code? I need code
Code:
application_surface_draw_enable(false);
surface_resize(application_surface, display_width, display_height);
In my all rooms. In all rooms i want to have the same camera and view settings.
So i can paste code in my room or create script.

But i must use code/script/scripts in all rooms. ctrl+c many times.
Is there any way to create "persistent code"?
There sure is. All you need to do is create an "obj_Camera" that is a persistent object that applies all of the code to your rooms.
So when you make the object, just have it sit somewhere in your room without a sprite. It will just be a happy little camera that no one ever sees but does all the camera work for you haha.


If you already have one script, just call it in the Step Event of your obj_Camera. :D
 
Top