Plubu
Member
Hello everyone,
I've seen videos of how to code a Parallax Backgrounds, it worked for me but it's not smooth, when the player stops or just starts moving, the background ike cuts off or something, it's not smooth.
This is my Camera object:
This is where I can change the speed of the parallax background:
This is where the camera follows the player, in the Player's object:
I think this is all the things that are related to the camera.
Many thanks.
I've seen videos of how to code a Parallax Backgrounds, it worked for me but it's not smooth, when the player stops or just starts moving, the background ike cuts off or something, it's not smooth.
This is my Camera object:
GML:
//Create
//Display Settings
IdealWidth = 1920;
IdealHeight = 1080;
Aspect_Ratio = display_get_width() / display_get_height();
IdealWidth = round(IdealHeight * Aspect_Ratio);
//Check for Odd Numbers
if (IdealWidth & 1)
{
IdealWidth += 1;
}
//Build a camera at (0,0), with size 640x480, 0 degrees of angle, no target instance, instant-jumping hspeed and vspeed, with a 32 pixel border
camera = camera_create_view(0, 0, IdealWidth, IdealHeight, 0, -1, -1, -1, 32, 32);
for(var i=1; i<= room_last; i++)
{
if (room_exists(i))
{
room_set_camera(i, 0, camera);
room_set_viewport(i,0,true, IdealWidth, IdealHeight, IdealWidth, IdealHeight);
}
}
surface_resize(application_surface, IdealWidth, IdealHeight);
window_set_size(IdealWidth, IdealHeight);
GML:
//Step
//Backgrounds
var _cam_x = camera_get_view_x(view_camera[0]) ;
layer_x("BG", _cam_x * 0.3); // Change the background layer name to whatever you use in the room editor
GML:
//End Step
#region Camera Folowing The Player
HalfWidth = camera_get_view_width(view_camera[0]) / 2;
HalfHeight = camera_get_view_height(view_camera[0]) / 2;
camera_set_view_pos(view_camera[0], x - HalfWidth, y - HalfHeight);
#endregion
Many thanks.