I'm having a problem with these functions. I have defined my hardware resolution (in the player) as 480x854. But these functions return 800 as the width (in landscape). Is this intentional? Because I can draw at -54 and it shows up. If I draw at 0, it shows up 54 pixels to the right.
Comments
In my case, even though I had a logical width of 800, the Gideros scaling did not do anything except lie to me about the true width, leaving that area undrawn. Yet, if I put something in that area deliberately, it would get drawn.
I'm not sure what i would prefer it to do for scaling, but if Gideros tells me I can't draw in an area (or that that area is outside my width), it would seem that drawing in that area should not show up.
How do you know about drawable areas outside the ContentWidth, if Gideros just offsets your content at 54 and tells you it's zero?
For elements of UI that you want to be in a certain position absolutely, you can do so, like described in this short tutorial: http://appcodingeasy.com/Gideros-Mobile/Ignore-Automatic-Screen-Scaling-when-positioning-objects
The dx and dy discussed in the tutorial are how much area is added/removed based on the scaling you've chosen. There's also some good discussions here about what the various scaling methods do, like here: http://www.giderosmobile.com/forum/discussion/1929/understanding-scaling-and-resolution-on-different-devices.#Item_40
I would like to explore the scaling options more, but it seems they are all faulty in one way or another (when it comes to my application). For example I have a scrollbar across the bottom that indicates how far you have scrolled left and right, but with letterbox this will look strange... it will indicate the letterboxed region is unscrollable, even though it is drawable, which would be jarring for the user.
If I am going to use a method to determine the "real" coordinates, then I do not see much value in the "logical" coordinates. What exactly do the logical coordinates mean to my app? They tell me where "zero" starts, but not where drawing starts. If I want to draw in the letterboxed area, then why am I bothering with letterbox at all?
I guess the value in that is for your app to know the bounds of where it can draw, then you fill in the rest with unnecessary filler, and bind buttons to absolute coordinates. But for a scrolling app, like mine, that seems like it wouldn't really work.
application:getDeviceHeight()/application:getDeviceWidth()
That lets me know if I'm on something ipad shaped, iphone4 shaped, iphone5 shaped and so on and I know whether 'filler' is in use compared with the 480x800 setting I'm using.
I use variables to set the positions of my buttons and, if filler is in use, place the buttons 'outside' the normal bounds (i.e. into the filler) where they still show and work. So, for example, a close button at top right of the screen is at top right on an ipad and also at top right on an iphone5 even though my logical dimensions are 480x800. Makes it look a lot more sensible to me!
I also use variables to adjust the positions of other elements to make the different shaped screens look as if they are being used more 'naturally', but only because of the nature of the content. If I could just get away with some extra filler, I would
I have my application working now. I have to say the scaling options are superior to what I had to do with Android. I still calculate my own virtual height and width, and draw things differently accordingly, but instead of scaling all the inputs and graphics, I just let gideros do it.
Here is what I ended up doing (when I detect I need to scale--otherwise I set it to noscale!):
It still drives me crazy that the logicalDimensions are backwards when in landscape mode, but you can't have everything I guess.