Xcode and Corona IPAD simulators don't agree

I use letterbox and scale my screen based in the device (eg, iPhone, iPad, kindle)
For iPad I scale my iPhone screen by 1.06 and 1.2 to take the 640x980 image to 768x1024.
On the corona iPad simulator the image fills the entire screen.
On the Xcode iPad simulator it doesn’t even look like its been scaled (black at bottom of screen etc)

Since I know I have scaling code I’m tempted to believe the corona simulator but this does make me nervous
Had anyone else seen this while trying to build for the 2 devices?
Thanks! [import]uid: 129205 topic_id: 22622 reply_id: 322622[/import]

I’m afraid you’re incorrectly using the scaling abilities of Corona. You’re not suppose to have to scale anything by yourself, it’s Corona’s job to do that.

It’s a bit complicated to completely understand the principles of letterbox scalling and be able to use it properly so if you really want to use you have to read a bit around, to understand it better.

From my understanding what you’re doing is that you first use letter box, and then scale the content to fill the screen. In that case you simply shouldn’t be using letterbox at all. There is a scalling mode that does exactly that, named zoomEven. This zoomEven scales the content so it fills the screen completely, but never distorting the image. There is a variation that is zoomStretch that scales the content but only on the axis needed. So in the case of an iPad (on portrait), it would increase the x scaling a bit to hit the margins of the screen, but this would distort the images a bit by changing the ratio.

Good read: http://blog.anscamobile.com/2010/11/content-scaling-made-easy/ [import]uid: 61899 topic_id: 22622 reply_id: 90212[/import]

Thanks for the reply. I have read quite a bit in preparation for handling the kindle with the menu bar at the bottom. My kindle code works great on the actual device. I don’t use a zoom for the reason that it messes with kindle . Is it possible to use letterbox for some devices and a zoom for others?
If not, I don’t see any way of corona scaling for me based on the need to use letterbox for kindle (to avoid the bottom menu bar from covering some of the play area).
Thanks again! [import]uid: 129205 topic_id: 22622 reply_id: 90218[/import]

Peach? … or anyone from corona? thanks! [import]uid: 129205 topic_id: 22622 reply_id: 90262[/import]

Hey interAlia, that’s a good question and one I am not totally sure on the answer for - I’m going to ask another member of the team and see if this is possible. [import]uid: 52491 topic_id: 22622 reply_id: 90429[/import]

Hello,

Here’s a description of letterbox scaling that I found…

Letterbox: Preserving the aspect ratio, it scales so it fits the content on the device screen. There’s a possibility that blank areas may occur on the device. Mostly, developer keeps the background a bit “bigger” in order to eliminate these blank areas and fill it with background.

In other words there will be bars on either top/bottom or left/right because the image is scaled until it fits in one direction and then the aspect ratio is preserved, thus leaving the bars.

HTH [import]uid: 8366 topic_id: 22622 reply_id: 90446[/import]

Let’s assume you’re coding on portrait orientation.

You set your config.lua for a screen of 320x480 pixels, letterbox scalling, and position centered both vertical and horizontal.

application = {  
 content = {  
 width = 320,  
 height = 480,  
 scale = "letterbox",  
 xAlign = "center",  
 yAlign = "center",  
 }  
}  

Now, when you create a background for the game, and you want to target iOS devices, so resolutions 320x480, 640x960 and 768x1024, you should do it like:

local bg = display.newImageRect("bg.png",360,480)  
bg.x = display.contentWidth/2  
bg.y = display.contentHeight/2  

The resolution of the image files should be:

bg.png - 360x480
bg@2.png - 720x960, or even 768x1024 if you want it to look really good on iPad.

Why this 360 pixel width?

Well, the thing is that with letter box, the images on higher resolutions than defined on config.lua will be scaled to fit the screen, but they won’t lose their aspect ratio, and that 320x480 rectangle you define on config.lua never goes out off screen.

Let’s see some examples. Start by assuming we did things the “normal” way. You call background images as 320x480, what would happen is:

iPhone - No scalling, config.lua already defines a rectangle of the size of the screen, so it would look fine.

iPhone4 - Scaling by a factor of 2, so the ratio is the same. Would look fine too, it would use double resolution image (640x960)

iPad - the 320x480 rect would grow by a factor of 2.1333…, ending up at a size of 682x1024. Since the iPad has a 768x1024 screen, you would notice some black bars on the sides.

Now lets assume you did as I said and called background images as 360x480.

iPhone - No scalling since config.lua defines a rectangle of screen size. The background though is a bit bigger for the screen and has some extra width compared to screen size. Since the background is centered, you would actualy not see some pixels to the sides. More exactly, 360-320 = 40, so 20 pixels to each side.

iPhone4 - Exactly the same case but on higher resolution, scalling by a factor of 2, usage of high res images.

iPad - Once again it will grow by a factor of 2.133, so a 360x480 images would grow to 768x1024, completely filling the iPad screen. No black bars. Usage of high resolution images.

Basically, using this you create the backgrounds with some extra areas that will only be shown when the screen has a different ratio. The screen will always be filled. You have to keep in mind though that anything out of the 320x480 center rectangle of an image (considering low res images), will not show on some devices, so don’t base you game in that areas, use it just for filling.

On Android the case is a bit different since the screen is actually taller (on portrait). So instead of having to increase width of background images from 320 to 360, you have to increase their height, from 480 to…
Well, considering all available android devices that number is 570.

In the case you want to completely support all resolutions of all phones/tablets available today, you should:

config.lua:

application = {  
 content = {  
 width = 320,  
 height = 480,  
 scale = "letterbox",  
 xAlign = "center",  
 yAlign = "center",  
 }  
}  

Instantiation of images for backgrounds:

local bg = display.newImageRect("bg.png",360,570)  
bg.x = display.contentWidth/2  
bg.y = display.contentHeight/2  

Low res images: 360x570 pixels
High res images: 720x1120 pixels
Remember that when you’re coding though, you’re coding for the rect defined on config.lua, so you’re coding for a screen of 320x480. If for example on iPad you want to refer to the left of the screen it will not be 0, as 0 is a bit distant from the border, as iPad is wider and this 320x480 rect preserves aspect ratio. So you should actualy rely on some corona defined values to help you. For any device you can define the top, left, right and bottom points as:

Top:

local topY = display.screenOriginY

Right:

local rightX = display.contentWidth - display.screenOriginX

Bottom:

local bottomY = display.contentHeight - display.screenOriginY

Left:

local rightX = display.screenOriginX

Hope this helps everyone to understand letterbox a bit better! [import]uid: 61899 topic_id: 22622 reply_id: 90449[/import]

Thanks CluelessIdeas for the thorough explanation of letterbox. In my case I have objects entering the screen from below the “ground” so any black bars (which are actually transparent areas) would allow the player to see what is coming. For this reason I have to avoid black bars entirely. I don’t want to zoom because it chops off some of the desired gameplay area. My work around was to simlpy to use a black box to cover the objects when they are below “ground” (i.e., a true opaque black bar).

My only confusion was why everything scaled as I would have expected on the Corona IPad simulator but it doesn’t look like anything scaled in the xCode simulator. Makes me wonder if scaling is, in actuality, working. I don’t have an iPad so I cannot test it on an actual device to see if the corona scaling code is operational.

Thanks everyone… Peach, please let me know what you find out. : ) [import]uid: 129205 topic_id: 22622 reply_id: 90485[/import]