How To Scale A Background So That It Fits The Screen?

Is there a way code this so that a background auto scales to fit a screen for any device?

I use this but it’s not working with every background image I have:

background.x = display.contentCenterX

background.y = display.contentCenterY

I find if you use zoomeven and make your background image 1220 x 840 it should fit every device without black borders. Of course you won’t see all of the image on all devices but at least you get no black borders and it will look ok.

Thank you, but how do I change the resolution of my background image? And how can I use zoomeven?

Hi @beck,

The following guide should help you with this:

http://docs.coronalabs.com/guide/basics/configSettings/index.html

And here’s an additional method (tutorial) on the issue which many people have utilized:

http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/

Best regards,

Brent Sorrentino

I find if you use zoomeven and make your background image 1220 x 840 it should fit every device without black borders. Of course you won’t see all of the image on all devices but at least you get no black borders and it will look ok.

Thank you, but how do I change the resolution of my background image? And how can I use zoomeven?

Hi @beck,

The following guide should help you with this:

http://docs.coronalabs.com/guide/basics/configSettings/index.html

And here’s an additional method (tutorial) on the issue which many people have utilized:

http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/

Best regards,

Brent Sorrentino