I feel like the player starts back at the original point because that's where I've set them in the room. It wouldn't be a big problem with the starting room, but I feel like it would start to get worse when I add more branching off rooms. I want to make it so the player doesn't have a single set spawn in every room.
Also, I got the code for the Camera Object, I don't think it's based on collisions.
Create Event:
Code:
///Set Up Camera
cam = view_camera[0];
follow = oPlayer
view_w_half = camera_get_view_width(cam) * 0.5;
view_h_half = camera_get_view_height(cam) * 0.5;
xTo = xstart;
yTo = ystart;
Step Event:
Code:
///Update Camera
//Update Destination
if (instance_exists(follow))
{
xTo = follow.x;
yTo = follow.y;
}
//Update Object Position
x += (xTo -x) / 25;
y += (yTo -y) / 25;
x = clamp(x,view_w_half,room_width-view_w_half);
y = clamp(y,view_h_half,room_height-view_h_half);
//Update Camera View
camera_set_view_pos(cam,x-view_w_half,y-view_h_half);
In that case, you'll need to set the player's starting coordinates for each room based on where they entered. I'm not sure what your code is for going to the next room, but in my game I have invisible "doors" that, when the player touches them, sends them to the desired room and also changes their x/y coordinates to the desired coordinates, all right as the player touches the "door".
You'd need to make an obj_door.
In the create event:
Code:
new_room = noone;
new_x = noone;
new_y = noone;
Then, let's say you have four different rooms you can get to from just one central room (north,south,east,west). That would mean you need four doors, each with their own values for the variables we just set. To do that, you would go into the creation code of each door instance in your room. You get there by double clicking on the instance and selecting "creation code".
THEN, set the values you want for that specific door in that creation code.
Code:
new_room = room_2; //whatever you want
new_x = 10; //whatever you want
new_y = 50; //whatever you want
Now all we have to do is get that code to actually DO something. In the player object, make a collision event with the door object. In that collision event:
Code:
room_goto(other.new_room); //change to room specified in the door's creation code
x = other.new_x; //set player's x coordinate to the coordinate in the door's creation code
y = other.new_y; //set player's y coordinate to the coordinate in the door's creation code
There you go! I assume you know how to make objects collide with each other (collision masks, physics, solid, etc.). Just remember, if you're using physics, then x and y need to be phy_position_x and phy_position_y.
As for your cameras, I'm not sure why the view is so big in the second room. Double check and make sure the camera's width and height are the same as the first room's camera in the room properties. As for the jumping of the camera, go ahead and try to fix the player's coordinates first and then let me know if it persists... it shouldn't. Or you can try what I said above and just have the camera follow the player in the room properties... it's far easier.
P.S. If you want to keep your fade in/out effect when transitioning rooms, you would need to run the room transfer code AFTER the initial fade.