dynamic scaling imageSuffix not behaving as expected

so I’m using this as config.lua file: 

if string.sub(system.getInfo("model"),1,4) == "iPad" then     application =      {         content =         {         graphicsCompatibility = 1,  -- Turn on V1 Compatibility Mode             width = 360,             height = 480,             scale = "letterBox",             xAlign = "center",             yAlign = "center",             imageSuffix =              {                 ["@2"] = 1.4,                 ["@4"] = 3.0,             },         },         notification =          {             iphone = {                 types = {                     "badge", "sound", "alert"                 }             }         }     } elseif string.sub(system.getInfo("model"),1,2) == "iP" and display.pixelHeight \> 960 then     application =      {         content =         {         graphicsCompatibility = 1,  -- Turn on V1 Compatibility Mode             width = 320,             height = 568,             scale = "letterBox",             xAlign = "center",             yAlign = "center",             imageSuffix =              {                 ["@2"] = 1.4,                 ["@4"] = 3.0,             },         },         notification =          {             iphone = {                 types = {                     "badge", "sound", "alert"                 }             }         }     } elseif string.sub(system.getInfo("model"),1,2) == "iP" then     application =      {         content =         {         graphicsCompatibility = 1,  -- Turn on V1 Compatibility Mode             width = 320,             height = 480,             scale = "letterBox",             xAlign = "center",             yAlign = "center",             imageSuffix =              {                 ["@2"] = 1.4,                 ["@4"] = 3.0,             },         },         notification =          {             iphone = {                 types = {                     "badge", "sound", "alert"                 }             }         }     } elseif display.pixelHeight / display.pixelWidth \> 1.72 then     application =      {         content =         {         graphicsCompatibility = 1,  -- Turn on V1 Compatibility Mode             width = 320,             height = 570,             scale = "letterBox",             xAlign = "center",             yAlign = "center",             imageSuffix =              {                 ["@2"] = 1.4,                 ["@4"] = 3.0,             },         },     } else     application =      {         content =         {         graphicsCompatibility = 1,  -- Turn on V1 Compatibility Mode             width = 320,             height = 512,             scale = "letterBox",             xAlign = "center",             yAlign = "center",             imageSuffix =              {                 ["@2"] = 1.4,                 ["@4"] = 3.0,             },         },         notification =          {             iphone = {                 types = {                     "badge", "sound", "alert"                 }             }         }     } end

and i created 3 start buttons (playnow-btn.png, playnow-btn@2.png, playnow-btn@4.png) to test the dynamic scaling : 

   local screenGroup = self.view    playNowBtn = display.newImage("playnow-btn.png")    screenGroup:insert(playNowBtn)    playNowBtn.x = display.contentWidth / 2; playNowBtn.y = 700    transition.to( playNowBtn, { time=1500, y=150, transition=easing.inOutExpo } )

JwRciXi.png

i deliberately give the images different colours so i can see when they are swapped out, am i missing something ? 

You should not use display.newImage(). 

From the docs:

Note that display.newImageRect() should be used instead to load images when dynamic content scaling is enabled.

oky that dose the trick but when i try to use it in this code : 

local screenGroup = self.view local randomBackC = function() local i = display.newImageRect("Cloud1-"..tostring(math.random(1, 12))..".png") i.x = math.random (0, 450); i.y = -50-- -50 physics.addBody( i, { density=.3, bounce=0.3, friction=.3, radius=25, filter=backc1CollisionFilter } ) i.name = "backclouts1" i.isSensor = true i.rotation = math.random(-30,30) -- Rotate the object transition.to( i, { time=yForBack, y=600, transition=easing.OutExpo } ) i.gravityScale = 0.0 backC1T[#backC1T+1] = i end randomBack1 = timer.performWithDelay( 500, randomBackC, 0 )  

i’m getting a Attempt to index local ‘i’ (a nil value), any ideas ? 

I wonder if i is failing to actually be constructed since you are missing the image dimensions.  They are required.

image = display.newImageRect( "image.png", 100, 100 )

thanks :D 

You should not use display.newImage(). 

From the docs:

Note that display.newImageRect() should be used instead to load images when dynamic content scaling is enabled.

oky that dose the trick but when i try to use it in this code : 

local screenGroup = self.view local randomBackC = function() local i = display.newImageRect("Cloud1-"..tostring(math.random(1, 12))..".png") i.x = math.random (0, 450); i.y = -50-- -50 physics.addBody( i, { density=.3, bounce=0.3, friction=.3, radius=25, filter=backc1CollisionFilter } ) i.name = "backclouts1" i.isSensor = true i.rotation = math.random(-30,30) -- Rotate the object transition.to( i, { time=yForBack, y=600, transition=easing.OutExpo } ) i.gravityScale = 0.0 backC1T[#backC1T+1] = i end randomBack1 = timer.performWithDelay( 500, randomBackC, 0 )  

i’m getting a Attempt to index local ‘i’ (a nil value), any ideas ? 

I wonder if i is failing to actually be constructed since you are missing the image dimensions.  They are required.

image = display.newImageRect( "image.png", 100, 100 )

thanks :D