1
\$\begingroup\$

How to scale images to full screen on all devices, i want to use %

The method I've seen so far is to define pixels

image_variable_name = display.newImage( "testimage.jpg", 100, 300 )

I want to do something like

image_variable_name = display.newImage( "testimage.jpg", 100%, 100% )

But that won't work, I want something like fluid CSS, the image will maintain the size no matter what is the size of the screen. Is it possible?

\$\endgroup\$
2
\$\begingroup\$

Try using newImageRect() instead of newImage()

image_variable_name = display.newImageRect("testimage.jpg", display.contentWidth, display.contentHeight)
--then you have to center it: 
image_variable_name.x = display.contentWidth / 2
image_variable_name.y = display.contentHeight / 2
\$\endgroup\$
1
\$\begingroup\$

Actually Corona uses feature called dynamic scaling so it let you working within same virtual size - 320х480. You can even have different assets for different scale factors.

\$\endgroup\$
1
\$\begingroup\$

Use display.newImageRect(), except unlike display.newImage(), you now have to enter the width and height of the image you are feeding in (the actual file). This will now scale automatically.

Also, if you ever switch to landscape mode for your default orientation, make sure your config.lua still has the fields width and height as if you were in portrait mode. Its a weird gotcha.

Here's how I present a background picture which takes up the full screen of a landscape mode 1280 x 720 display (Galaxy S3):

menuBg = display.newImageRect( "images/bg.png", 1280, 720 )
menuBg:setReferencePoint( display.CenterLeftReferencePoint )
menuBg.x = 0
menuBg.y = display.contentHeight/2

Setting the reference point is of personal preference, so play with that yourself.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.