Background Image Question

I am working with a student who made a 512 x 512 background image. He was trying to have his sprite move across it similar to having a large tilemap and using the camera follow sprite block. Is there a way to do this?

It also looks like the editor is cropping the image? Is there a max size for a background image?

1 Like

Ah, so the issue is that background images are “fixed” to the camera. Here’s a quick example–the image is always centered on the camera even as the player moves through the tilemap:

You’ll want to instead create a fake background image sprite, set a tilemap to define the bounds of the world (otherwise the player can move infinitely in any direction), and center the background image sprite in that tilemap. Here’s the code for it!

3 Likes

Perfect! That’s great solution. I really appreciate the help.

I found the solution to be somewhat buggy. Maybe it was my computer, but after I while I could not move the sprite very well. Once it moved to an edge of the screen, I could not move the sprite anymore, and when I could the controller events were being queued up. There was a delay in movement. I suspect because the background image is so large.

1 Like

Oh, good call, the other thing that might be useful here is to set “ghost” to true for the image! It should significantly improve performance, as we’ll skip collision checking for the large background image.

image

3 Likes

Oh, I was experiencing the same thing. I didn’t make that connection though. I will test the ghost solution as well.
Thank you everyone. I appreciate it.

1 Like

That works much better, and is logical as well; no need to collide with the background :grin:
I might just have to use this example code for my next game.

3 Likes