• 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!

Parallax backgrounds

Hi can someone help me, I cant understand why my background is starting mid screen and not taking the full width of the screen. I have been following Shaun Spaldings tutorial on this but it doesnt seem to work for me.


here is my code...
Code:
///Create camera

cam = view_camera[0];
follow = oHamish;
view_w_half = camera_get_view_width(cam) * 0.5;
view_h_half = camera_get_view_height(cam) * 0.5;
xTo = xstart;
yTo = ystart;

//BGLayer01 = laye
And for the event...
Code:
///Update camera

//Update destination
if (instance_exists(follow))
{
    xTo = follow.x;
    yTo = follow.y;
}

//Update object posititon
x += (xTo - x) / 25;
y += (yTo - y) / 25;

//keep camera in centre inside room

x = clamp(x,view_w_half,room_width-view_w_half);

//Update camera view
camera_set_view_pos(cam,x-view_w_half,y-view_h_half);

if (layer_exists("Background02"))
{
    layer_x("Background02",x);
}
 
Just as an Update! This was due to tiling. The way the code sets it up requires the background to tile. Just though Id let you know for anyone else using one piece of art for the BG.
 
Top