• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Questions concerning camera/view/layer

NazGhuL

NazTaiL
Hi!
1-About setting up a camera in a 'boot' room or main menu. I'm used to create a persistent object for display. (toggle fullscreen, hud and now cameras). When creating a camera or assigning it to a view, on a persistent object, should you destroy the camera at the end of each room and re-create it on each start?(and re-assign it)

2- If you create a layer, is it 'attached' to the room? let me explain that one:
on room0
Code:
global.the_layer = layer_create(-100);
with(instance_create_layer(x1, y1, global.the_layer, obj_box))
{
persistent = 1;
}
room_goto(room1)
Now we're on room1.
The layer still exists? Suppose to, It's not deleted. Is the obj_box still on it? On the new room?
(Will test this one soon but maybe some of you have already did this)
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
1) If you are simply doing this:

Code:
view_camera[0] = camera_create_view(blah);
then yes, you'll need to destroy it. If however you do this:

Code:
global.cam = camera_create_view(blah);
view_camera[0] = global.cam;
then no, as it's being stored in a global variable and you can simply apply the global camera to any view at the start of the room.

2) No idea! Test it and see! I would assume that if you create the layer and the room is persistent then that room will still have the layer (and any instances/tiles/etc... assigned to it).
 

NazGhuL

NazTaiL
Looks like a layer is not passed through room.
The way I see this is you should create layers at the start of the room then destroy it at the end.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Looks like a layer is not passed through room.
So, you're saying that a new layer created in a persistent room isn't there when you leave and go back to the room? Could you detail what you've done for testing this? I'll ask the devs about it as it may be a bug...
 

NazGhuL

NazTaiL
No no. Object persistent, not Room.

On room0
Code:
global.My_Layer = layer_create(-100);
instance_create_layer(100, 100, global.My_Layer, object_1);
global.My_Layer returns 4.

Then when going to room1 global.My_Layer returns -1.

Going back to room0 global.My_Layer returns -1.

My original question should be: On witch layer an instance is in a case like this: -1.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Ah! In that case yes, this is expected behaviour... Layers cannot be carried across rooms, so when you create a layer in a room and store it's ID, that ID is only valid in the room it was created in. I would imagine that if the room you created it in was persistent, then when you returned to that room the global variable with the layer ID would be valid again. If the room is NOT persistent then the layer is lost when you exit the room and you'll need to recreate it again on room start (and it'll have a different ID too).
 
Top