@2x High Resolution Images Not Working

Hi all, I’m just starting to learn how to use Corona and I’ve hit a problem with my High Resolution Images never being displayed.

I read the tutorial over at http://www.coronalabs.com/blog/2013/09/10/modernizing-the-config-lua/ and used the config.lua provided to make an 800x1200 content area:

local aspectRatio = display.pixelHeight / display.pixelWidth application = { content = { width = aspectRatio \> 1.5 and 800 or math.ceil( 1200 / aspectRatio ), height = aspectRatio \< 1.5 and 1200 or math.ceil( 800 \* aspectRatio ), scale = "letterBox", fps = 30, imageSuffix = { ["@2x"] = 1.3, }, }, }

I created two images: Test.png (256x256) and Test@2x.png (512x512) which are both a solid color (one is gray the other is green). I added the normal image in my main.lua and placed it in the center of the screen:

local testimage = display.newImage( "Test.png", 400, 600 )

Corona will only display the normal sized image and never use the high resolution version regardless of simulator that I use. It also slightly offsets the image to the top left of the screen for most simulators (S3, iPad Retina, iPad).

Does anyone see what I have done wrong?

You need to use display.newImageRect.

Doh! :wacko:

I knew it was something simple I was missing. Thank you!

You need to use display.newImageRect.

Doh! :wacko:

I knew it was something simple I was missing. Thank you!

Hi,

My images [@2x] are working, but I would like know one thing .

Just to be sure, because I’m printing the width of the object (object.width) but  this one is never changing while the image yes (I’ve made one image white and the biggerOne blue), Is it normal ?

Thanks

object.width will be the width based on what you used when you called display.newImageRect().

In other words:

local image1 = display.newImageRect( “image.png”, 100, 100)

print(image1.width) – outputs 100

local image2 = display.newImageRect( “image.png”, 200, 200)

print(image2.width) – outputs 200

Notice both were the same image file, just with a different default height/width.

Rob

Ok thanks Rob, 

is there a way to check, the width or height of the [@2x] image ?
If not,  doesn’t matter , I’m just a little bit maniac, to check if everything work as I expect  :stuck_out_tongue:

You can make the images a little different if you want to verify it.  But in reality, it just works. If you need to get the actual dimensions then you can use any image editing tool to look at the images and get their size.

Rob

Hi,

My images [@2x] are working, but I would like know one thing .

Just to be sure, because I’m printing the width of the object (object.width) but  this one is never changing while the image yes (I’ve made one image white and the biggerOne blue), Is it normal ?

Thanks

object.width will be the width based on what you used when you called display.newImageRect().

In other words:

local image1 = display.newImageRect( “image.png”, 100, 100)

print(image1.width) – outputs 100

local image2 = display.newImageRect( “image.png”, 200, 200)

print(image2.width) – outputs 200

Notice both were the same image file, just with a different default height/width.

Rob

Ok thanks Rob, 

is there a way to check, the width or height of the [@2x] image ?
If not,  doesn’t matter , I’m just a little bit maniac, to check if everything work as I expect  :stuck_out_tongue:

You can make the images a little different if you want to verify it.  But in reality, it just works. If you need to get the actual dimensions then you can use any image editing tool to look at the images and get their size.

Rob