zoomStretch scaling bug?

Hi,

Just recently, I added tall screen support for my app and it works great on an iPhone 5 but not on the iPod Touch 5th gen. I’m not sure but I’m guessing it has something to do with the “zoomStretch” scale mode because games using “letterbox” are not affected. I’ve attached some screenshots to show the difference.

Hope you can shed some light into this issue CoronaLabs?

Thank you,

Erick

Running on iPhone 5 using Corona DB 936
http://dl.dropbox.com/u/6846209/shot2.png

Running on iPod Touch using Corona DB 936
http://dl.dropbox.com/u/6846209/shot1.png [import]uid: 44127 topic_id: 32730 reply_id: 332730[/import]

Hey, Erick, I’m wondering if you’ve added the Default-568h@2x.png file to your iPod Touch 5G… It may not be your problem, but just in case this is caused by some sort of caching issue, will you delete your app from your iPod Touch 5G (assuming the app is identical to the version you installed on your iPhone 5 which is working/looking perfectly) and then reinstall it. Does it fix the problem?

Naomi

Edit: Wait. I just realized you are using letterbox in the version you installed on iPhone5, but using zoomStretch in the version you installed on iPod Touch 5G. Why, though? If the letterbox version works on iPhone5, why do you want to use zoomStretch version on iPod Touch 5G? Maybe… are you tracking down bug/issue for Corona Labs to fix… or, maybe checking to see how zoomStretch works for tall device? [import]uid: 67217 topic_id: 32730 reply_id: 130117[/import]

Hi Naomi,

Thank you for the quick response. I’m actually using zoomStretch for everything but it appears like that on the iPod Touch. Below is my config.lua. Is it because of the targetDevice? Does the iPod Touch have a different “device” name?

EDIT: Forgot to answer your other question–yes I’m pretty sure the Default-568h@2x.png (with the correct filename) is included. I see it displaying well on my iPhone 5. Sadly though, I don’t have an iPod Touch 5th gen–the screenshot was just sent to me by a player.

============
– config.lua

local targetDevice = ( system.getInfo( “model” ) )
local isTall = ( targetDevice == “iPhone” ) and ( display.pixelHeight > 960 )

if ( isTall == true ) then
application =
{
content =
{
width = 320,
height = 568,
scale = “zoomStretch”,

imageSuffix =
{
["_2x"] = 2,
}
},

notification =
{
iphone =
{
types =
{
“badge”, “sound”, “alert”
}
}
}
}
else
application =
{
content =
{
width = 320,
height = 480,
scale = “zoomStretch”,

imageSuffix =
{
["_2x"] = 2,
}
},

notification =
{
iphone =
{
types =
{
“badge”, “sound”, “alert”
}
}
}
}
end [import]uid: 44127 topic_id: 32730 reply_id: 130119[/import]

Hey, Erick, I’m wondering if you’ve added the Default-568h@2x.png file to your iPod Touch 5G… It may not be your problem, but just in case this is caused by some sort of caching issue, will you delete your app from your iPod Touch 5G (assuming the app is identical to the version you installed on your iPhone 5 which is working/looking perfectly) and then reinstall it. Does it fix the problem?

Naomi

Edit: Wait. I just realized you are using letterbox in the version you installed on iPhone5, but using zoomStretch in the version you installed on iPod Touch 5G. Why, though? If the letterbox version works on iPhone5, why do you want to use zoomStretch version on iPod Touch 5G? Maybe… are you tracking down bug/issue for Corona Labs to fix… or, maybe checking to see how zoomStretch works for tall device? [import]uid: 67217 topic_id: 32730 reply_id: 130117[/import]

Hi Naomi,

Thank you for the quick response. I’m actually using zoomStretch for everything but it appears like that on the iPod Touch. Below is my config.lua. Is it because of the targetDevice? Does the iPod Touch have a different “device” name?

EDIT: Forgot to answer your other question–yes I’m pretty sure the Default-568h@2x.png (with the correct filename) is included. I see it displaying well on my iPhone 5. Sadly though, I don’t have an iPod Touch 5th gen–the screenshot was just sent to me by a player.

============
– config.lua

local targetDevice = ( system.getInfo( “model” ) )
local isTall = ( targetDevice == “iPhone” ) and ( display.pixelHeight > 960 )

if ( isTall == true ) then
application =
{
content =
{
width = 320,
height = 568,
scale = “zoomStretch”,

imageSuffix =
{
["_2x"] = 2,
}
},

notification =
{
iphone =
{
types =
{
“badge”, “sound”, “alert”
}
}
}
}
else
application =
{
content =
{
width = 320,
height = 480,
scale = “zoomStretch”,

imageSuffix =
{
["_2x"] = 2,
}
},

notification =
{
iphone =
{
types =
{
“badge”, “sound”, “alert”
}
}
}
}
end [import]uid: 44127 topic_id: 32730 reply_id: 130119[/import]

Hi Erick, about system.getInfo( “model” ), I don’t think iPod Touch returns “iPhone” – but the best way to find out is actually checking it on device, using print statement, like so:

local thisDevice = system.getInfo( "model" )   
print("thisDevice = ", thisDevice )  

Alternatively, you may want to consider:

-- change the following:  
local targetDevice = ( system.getInfo( "model" ) )  
local isTall = ( targetDevice == "iPhone" ) and ( display.pixelHeight \> 960 )  
  
-- to this:  
local targetDevice = ( system.getInfo( "model" ) )  
local isTall = ( targetDevice ~= "iPad" ) and ( display.pixelHeight \> 960 )  
  
-- EDIT: BTW, I'm assuming this config.lua is intended only for iOS device.  

I hope this helps.

Naomi [import]uid: 67217 topic_id: 32730 reply_id: 130160[/import]

The iPod Touch system.getInfo(“model”) returns ‘iPod Touch’, which means that your config.lua won’t recognize it properly.
[import]uid: 134101 topic_id: 32730 reply_id: 130161[/import]

Actually, it might be better to include “iPod Touch” (as @Ntero noted) to the if-statement (rather than doing the if-not-iPad) – because it just occurred to me that iPad mini may not return “iPad” as the model.

BTW, if anyone knows what system.getInfo( “model” ) returns for iPad mini, I’d so appreciate hearing about it.

Naomi [import]uid: 67217 topic_id: 32730 reply_id: 130166[/import]

Looking at the config file provided, you can clean this up drastically:

local width, height = 0, 0  
if display.pixelHeight % 1024 == 0 then --It's an iPad height  
 width, height = 768, 1024  
else if display.pixelHeight % 568 == 0 then --It's an iOS Tall height  
 width, height = 320, 568  
else --Must be iOS normal  
 width, height = 320, 480  
end  
  
application =  
{  
 content =  
 {  
 width = width,  
 height = height,  
 scale = "zoomStretch",  
  
 imageSuffix =  
 {  
 ["\_2x"] = 2,  
 }  
 },  
  
 notification =  
 {  
 iphone =  
 {  
 types =  
 {  
 "badge", "sound", "alert"  
 }  
 }  
 }  
}  

This way you avoid massive switches of identical content in if statements, and easily read and understand the processing done strictly at the top, making it easier to edit later to add more devices.

The modulo operator (%) means you can handle both retina and non-retina in one swoop, as so long as it’s a multiple of the smallest available size, it’s a match.

Edit: It also means you are no longer relying on iOS model types at all, because the actual resolution is all that’s really important (if they made a 320 x 568 iPad, you’d still want to treat it like a 320 x 568 screen, since the actual model name is only a helper and not really relevant). [import]uid: 134101 topic_id: 32730 reply_id: 130169[/import]

Hi Erick, about system.getInfo( “model” ), I don’t think iPod Touch returns “iPhone” – but the best way to find out is actually checking it on device, using print statement, like so:

local thisDevice = system.getInfo( "model" )   
print("thisDevice = ", thisDevice )  

Alternatively, you may want to consider:

-- change the following:  
local targetDevice = ( system.getInfo( "model" ) )  
local isTall = ( targetDevice == "iPhone" ) and ( display.pixelHeight \> 960 )  
  
-- to this:  
local targetDevice = ( system.getInfo( "model" ) )  
local isTall = ( targetDevice ~= "iPad" ) and ( display.pixelHeight \> 960 )  
  
-- EDIT: BTW, I'm assuming this config.lua is intended only for iOS device.  

I hope this helps.

Naomi [import]uid: 67217 topic_id: 32730 reply_id: 130160[/import]

The iPod Touch system.getInfo(“model”) returns ‘iPod Touch’, which means that your config.lua won’t recognize it properly.
[import]uid: 134101 topic_id: 32730 reply_id: 130161[/import]

Actually, it might be better to include “iPod Touch” (as @Ntero noted) to the if-statement (rather than doing the if-not-iPad) – because it just occurred to me that iPad mini may not return “iPad” as the model.

BTW, if anyone knows what system.getInfo( “model” ) returns for iPad mini, I’d so appreciate hearing about it.

Naomi [import]uid: 67217 topic_id: 32730 reply_id: 130166[/import]

Looking at the config file provided, you can clean this up drastically:

local width, height = 0, 0  
if display.pixelHeight % 1024 == 0 then --It's an iPad height  
 width, height = 768, 1024  
else if display.pixelHeight % 568 == 0 then --It's an iOS Tall height  
 width, height = 320, 568  
else --Must be iOS normal  
 width, height = 320, 480  
end  
  
application =  
{  
 content =  
 {  
 width = width,  
 height = height,  
 scale = "zoomStretch",  
  
 imageSuffix =  
 {  
 ["\_2x"] = 2,  
 }  
 },  
  
 notification =  
 {  
 iphone =  
 {  
 types =  
 {  
 "badge", "sound", "alert"  
 }  
 }  
 }  
}  

This way you avoid massive switches of identical content in if statements, and easily read and understand the processing done strictly at the top, making it easier to edit later to add more devices.

The modulo operator (%) means you can handle both retina and non-retina in one swoop, as so long as it’s a multiple of the smallest available size, it’s a match.

Edit: It also means you are no longer relying on iOS model types at all, because the actual resolution is all that’s really important (if they made a 320 x 568 iPad, you’d still want to treat it like a 320 x 568 screen, since the actual model name is only a helper and not really relevant). [import]uid: 134101 topic_id: 32730 reply_id: 130169[/import]

I thought this Kickstarter project was beyond cool. These brothers are building a 3D flight simulator using a robot ball as the controller. It appears that its for the iPad and iPhone. I think this is a very unique idea and I want to try their app! http://www.kickstarter.com/projects/858730843/sphero-glide [import]uid: 193761 topic_id: 32730 reply_id: 130231[/import]

I thought this Kickstarter project was beyond cool. These brothers are building a 3D flight simulator using a robot ball as the controller. It appears that its for the iPad and iPhone. I think this is a very unique idea and I want to try their app! http://www.kickstarter.com/projects/858730843/sphero-glide [import]uid: 193761 topic_id: 32730 reply_id: 130231[/import]

Thanks for the help Naomi and Ntero! I really appreciate it guys! My issue is now officially solved! :slight_smile: This would’ve been easier if I had an iPod Touch 5th gen though.

Just curious, why not just–

if display.pixelHeight == 1136 then

instead of

if display.pixelHeight % 568 == 0 then

Is there a huge difference? [import]uid: 44127 topic_id: 32730 reply_id: 130247[/import]

Thanks for the help Naomi and Ntero! I really appreciate it guys! My issue is now officially solved! :slight_smile: This would’ve been easier if I had an iPod Touch 5th gen though.

Just curious, why not just–

if display.pixelHeight == 1136 then

instead of

if display.pixelHeight % 568 == 0 then

Is there a huge difference? [import]uid: 44127 topic_id: 32730 reply_id: 130247[/import]

Spoke too soon guys! I used Ntero’s config.lua but when I had the build tested on a friend’s iPod Touch 5th gen, the result is still the same. Works fine on my iPhone 5 but not on the iPod Touch.

Running out of ideas here. :S [import]uid: 44127 topic_id: 32730 reply_id: 130294[/import]

Spoke too soon guys! I used Ntero’s config.lua but when I had the build tested on a friend’s iPod Touch 5th gen, the result is still the same. Works fine on my iPhone 5 but not on the iPod Touch.

Running out of ideas here. :S [import]uid: 44127 topic_id: 32730 reply_id: 130294[/import]

@Ntero’s config.lua has a small problem:

local width, height = 0, 0  
if display.pixelHeight % 1024 == 0 then --It's an iPad height  
 width, height = 768, 1024  
else if display.pixelHeight % 568 == 0 then --It's an iOS Tall height  
 width, height = 320, 568  
else --Must be iOS normal  
 width, height = 320, 480  
end  
   

For things that are not iPad, they are scaled at 320px. For the iPad they are scaled at 768px. If you’re using 320 as the base, that should be:

width, height = 360, 480

For me I do something like this:

if string.sub( system.getInfo( "model" ),1,4) == "iPad" then  
 width, height = 360, 480  
elseif string.sub(system.getInfo("model",1,2) == "iP" and display.pixelHeight \> 960 then  
 width, height = 320, 568  
else  
 width, height = 320, 480  
end  

or something similar using @Ntero’s way of doing things.

EDIT to add: The reason I don’t just check system.getInfo(“model”) against “iPad” and do a sub-string is because if you’re running this in Apple’s simulator the model is “iPad Simulator”. Also we don’t know what model the iPad mini is going to return yet and if it’s iPad Mini then the sub-string bit future protects us.
[import]uid: 19626 topic_id: 32730 reply_id: 130304[/import]