@2x not working

Hi guys, in order to optimize my app for the retina display, I’ve used the “ultimate config.lua file”, and added  “@2x” images in my app’s folder.

I’ve tested it on an iPhone 5, but unfortunately, I get only the previous-retina display images.

How can I fix this problem?
 

Thanks! :slight_smile:

Can you be more descriptive of the problem?  Are you working with iPads?  Are you not getting full screen on the iPhone 5?

No, I get the “tall” resolution of the iphone 5, i Justine don’t get the @2x images, and I’m not working with iPads

Hi @lorenzoestienne4,

Most likely there’s just one incorrect aspect in your “config.lua” setup. Can you paste the code for that here?

Brent

Sure, here it is:

[lua]

application = {

    content = {

        width = 320,

        height = 480, 

        --scale = “zoomEven”

        scale = “letterBox”,

        fps = 60,

        

        

        imageSuffix = {

            ["@2x"] = 2,

        }

        

    }

}

– For iPads

if system.getInfo(“model”) == “iPad” or system.getInfo(“model”) == “iPad Simulator” then

        

        application = {

                content = {

                        width = 360,

                height = 480,

                        scale = “zoomEven”,

                        audioPlayFrequency=“44100”,

                        fps = 60,

                        imageSuffix = {

                            ["@2x"] = 2,

                                ["@4x"] = 4,

                        }

                }

        }

        

– For “tall” sizes (iPhone 5 and new iTouch)

elseif display.pixelHeight > 960 then

        application = {

                content = {

                        width = 320,

                        height = 568, 

                        scale = “zoomEven”,

                        audioPlayFrequency=“44100”,

                        fps = 60,

                        imageSuffix = {

                            ["@2x"] = 2,

                        }

                }

        }

else – For traditional sizes (iPhone 4S & below, old iTouch)

        application = {

                content = {

                        width = 320,

                        height = 480, 

                        scale = “zoomEven”,

                        audioPlayFrequency=“44100”,

                        fps = 60,

                        imageSuffix = {

                            ["@2x"] = 2,

                        }

                }

        }

                

end

[/lua]

When you say you are not getting your @2x images, how are you determining that?  Are they not sharp?  Can you temporarily put some additional feature on an @2x file to see if it’s loading or not (like adding some text or a colored dot)?

How are your files actually named?

Yes, they aren’t sharp, I’m sure of that because they are not in high-def, and in my lua file I declare images as they are called in the image folder.

For example, I’ve got player.png and player@2x.png, and in the lua script I use

[lua]

local player = display.newImage(“player.png”)

[/lua]

I’ve solved! I found out that I had to use 

[lua]

local player = display.newImageRect(“player.png”)

[/lua]

instead of

[lua]

local player = display.newImage(“player.png”)

[/lua]

Thanks anyway!

Can you be more descriptive of the problem?  Are you working with iPads?  Are you not getting full screen on the iPhone 5?

No, I get the “tall” resolution of the iphone 5, i Justine don’t get the @2x images, and I’m not working with iPads

Hi @lorenzoestienne4,

Most likely there’s just one incorrect aspect in your “config.lua” setup. Can you paste the code for that here?

Brent

Sure, here it is:

[lua]

application = {

    content = {

        width = 320,

        height = 480, 

        --scale = “zoomEven”

        scale = “letterBox”,

        fps = 60,

        

        

        imageSuffix = {

            ["@2x"] = 2,

        }

        

    }

}

– For iPads

if system.getInfo(“model”) == “iPad” or system.getInfo(“model”) == “iPad Simulator” then

        

        application = {

                content = {

                        width = 360,

                height = 480,

                        scale = “zoomEven”,

                        audioPlayFrequency=“44100”,

                        fps = 60,

                        imageSuffix = {

                            ["@2x"] = 2,

                                ["@4x"] = 4,

                        }

                }

        }

        

– For “tall” sizes (iPhone 5 and new iTouch)

elseif display.pixelHeight > 960 then

        application = {

                content = {

                        width = 320,

                        height = 568, 

                        scale = “zoomEven”,

                        audioPlayFrequency=“44100”,

                        fps = 60,

                        imageSuffix = {

                            ["@2x"] = 2,

                        }

                }

        }

else – For traditional sizes (iPhone 4S & below, old iTouch)

        application = {

                content = {

                        width = 320,

                        height = 480, 

                        scale = “zoomEven”,

                        audioPlayFrequency=“44100”,

                        fps = 60,

                        imageSuffix = {

                            ["@2x"] = 2,

                        }

                }

        }

                

end

[/lua]

When you say you are not getting your @2x images, how are you determining that?  Are they not sharp?  Can you temporarily put some additional feature on an @2x file to see if it’s loading or not (like adding some text or a colored dot)?

How are your files actually named?

Yes, they aren’t sharp, I’m sure of that because they are not in high-def, and in my lua file I declare images as they are called in the image folder.

For example, I’ve got player.png and player@2x.png, and in the lua script I use

[lua]

local player = display.newImage(“player.png”)

[/lua]

I’ve solved! I found out that I had to use 

[lua]

local player = display.newImageRect(“player.png”)

[/lua]

instead of

[lua]

local player = display.newImage(“player.png”)

[/lua]

Thanks anyway!

This answer is not correct.

width and height are for some reason, required. As I just painfully learned. Someone correct me if I am wrong but considering this is one of the few threads covering this topic, it was frustrating to see this marked as correct.

From the docs:

http://docs.coronalabs.com/api/library/display/newImageRect.html

@Hive, you are correct. Width and height are required by “newImageRect()”. This is how Corona gets the “base 1x” size that is used to then extrapolate out higher resolution images.

Best regards,

Brent

This answer is not correct.

width and height are for some reason, required. As I just painfully learned. Someone correct me if I am wrong but considering this is one of the few threads covering this topic, it was frustrating to see this marked as correct.

From the docs:

http://docs.coronalabs.com/api/library/display/newImageRect.html

@Hive, you are correct. Width and height are required by “newImageRect()”. This is how Corona gets the “base 1x” size that is used to then extrapolate out higher resolution images.

Best regards,

Brent