Image Auto Selecting problem

hello,

I am trying to auto select images in my game but I have a problem doing it because It seems like the images are not being recognized, I have set the key pair values in the config file as well as check the images name in the game folder but I doesn’t look like is working I got a message saying I am pointing to a null value 

the code I got in my config.lua is the following:
 

system.getInfo(“model”)

if ( string.sub( system.getInfo(“model”), 1, 4 ) == “iPad” ) then

application = {

content = {

width = 768,

height = 1024, 

scale = “letterBox”,

fps = 30,

        imageSuffix = {

   ["@2x"] = 0.375,

            ["@4x"] = 1.5,

}

},

    --[[

    – Push notifications

    notification =

    {

        iphone =

        {

            types =

            {

                “badge”, “sound”, “alert”, “newsstand”

            }

        }

    }

    --]]    

}

else

application = {

    content = {

        width = 720,

        height = 1280, 

        scale = “letterBox”,

        fps = 30,

        imageSuffix = {

            ["@2x"] = 0.375,

            ["@4x"] = 1.5,

        }

    },

    --[[

    – Push notifications

    notification =

    {

        iphone =

        {

            types =

            {

                “badge”, “sound”, “alert”, “newsstand”

            }

        }

    }

    --]]    

}   

end

The code of my game that is calling the images is the following:

local background = display.newImageRect( “mysplash_screen.jpg”, display.contentWidth, display.contentHeight )

background.anchorX = 0

background.anchorY = 0

background.x, background.y = 0, 0

and the 2 images I got in the game folder are named:
mysplash_screen@2x.jpg

mysplash_screen@4x.jpg

the line local background = display.newImageRect( “mysplash_screen.jpg”, display.contentWidth, display.contentHeight )  is the one I am getting the error from but if I change the name of the image to match the ones I got in the folder named like the ones above starts working so I guess sht is wrong with the dynamic Image selection.

I do really need help to fix this issue

Regards.

 

If I did the math right, you will only get the normal version if your screen is under 288px wide.  Anything between and 1152px wide would get the @2x version and any device wider than 1152 will get the @2x image and anything more would be the @4x image.

Are you testing this in the Corona sim or on a device?  What skin are you using if you’re using the simulator or what device are you seeing this on?

How do you know which one you are getting?

I was testing with the emulator and also with 2 devices a 320x480 and 600x1200 device both of the same brand… and now it is working, I have the following configuration but just to make sure so devices on width between 270  and 576 will use the @2x copy if the width is higher than that then it will use @4x and if the width is lower than 270 then it will use the default non-suffixed image? and I also had another question, will it change anything if I set portrait or landscape configuration… they are going to swap or still the same?

content = {

        width = 720,

        height = 1280, 

        scale = “letterBox”,

        fps = 30,

        imageSuffix = {

             ["@2x"] = 0.375,

             ["@4x"] = 0.8,

        }

    }

If I did the math right, you will only get the normal version if your screen is under 288px wide.  Anything between and 1152px wide would get the @2x version and any device wider than 1152 will get the @2x image and anything more would be the @4x image.

Are you testing this in the Corona sim or on a device?  What skin are you using if you’re using the simulator or what device are you seeing this on?

How do you know which one you are getting?

I was testing with the emulator and also with 2 devices a 320x480 and 600x1200 device both of the same brand… and now it is working, I have the following configuration but just to make sure so devices on width between 270  and 576 will use the @2x copy if the width is higher than that then it will use @4x and if the width is lower than 270 then it will use the default non-suffixed image? and I also had another question, will it change anything if I set portrait or landscape configuration… they are going to swap or still the same?

content = {

        width = 720,

        height = 1280, 

        scale = “letterBox”,

        fps = 30,

        imageSuffix = {

             ["@2x"] = 0.375,

             ["@4x"] = 0.8,

        }

    }