[SOLVED] Background fixed to the screen size?

Drazglb.

Member
Hi guys,
I'm totally new here, so I hope I make things right...
So here's my issue: I want a static background which would always be the same no matter where the player is (I'm making a 2d platformer). I also want to stretch that background so it fits the screen size too.

I hope someone could give me a hint, because I already lost 3 days searching for a solution.
Thank you!
 
T

Taddio

Guest
There is a "stretch" box you can tick in the background layers in the room editor.
For the background "following" the player, it would depend how you are currently set up. Are you using a camera that follows the player? You see the whole level at once?
 

Drazglb.

Member
Actually the stretch box fill the entire room, not the view. And my rooms are quite big.
As for the camera, It is for now a coded one, I am not using the room editor, and this code simply follows my character who is fixed at the center of the view.
 
T

Taddio

Guest
You could probably use layer_sprite_x/y, to lock it to it around the player and use viewport size w/h to get your scaling factor. Can't do much more with the info you provided, sorry.
Good luck
 
Forget layer settings, make a layer where you want the background, not a background layer but an asset layer. make an object that draws your background. for the draw event make it

Code:
draw_sprite(background, 0, camera_get_view_x(camera), camera_get_view_y(camera));
if you made the background the same size as your view you can end there.

if not, you need to mess with the image_xscale and image_yscale

Code:
draw_sprite_ext(background, 0, camera_get_view_x(camera), camera_get_view_y(camera), xscale, yscale, 0, c_white, 1);
 

Joe Ellis

Member
display_get_width(), \height is what you want. draw the background stretched to that size
or if your in windowed mode, window_get_width\height,
I also set room_width\height to this to avoid having to keep doing the display\window size function
 
Top