Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
getContentWidth/Height returns 800 when player is set to 480x854 — Gideros Forum

getContentWidth/Height returns 800 when player is set to 480x854

adiposeadipose Member
edited January 2013 in General questions
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

  • zvardinzvardin Member
    Accepted Answer
    If you right-click on your project, there are dimensions you can set for your project. Gideros will scale your game for whatever the hardware dimensions are you're using, unless you've turned off scaling. My guess is your project has 800 for width.
  • Thank you, that was the issue all right. Personally, it seems like scaling is a bad idea, as no matter what aspect ratio you use logically, there will be "black bars" on some screens, no?

    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?
  • Well, with so many devices out there, scaling can be great, but you just have to setup everything for it. You can choose which scaling mode suits you and then make sure there is extra background etc to handle it.

    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
  • Thanks again. Those threads are very informative. I will probably end up using the no-scale option as I came from Android and I had already implemented all necessary scaling in software.

    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.
  • 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.
    Unnecessary filler and letterbox might not be quite as restricting as it first seems. I use it in my apps. I find the aspect ratio of the screen using:

    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 :)
  • adiposeadipose Member
    edited January 2013
    Thanks for all the comments.

    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!):
    	application:setLogicalDimensions(cnvsHeight, cnvsWidth)
    	application:setScaleMode("fitWidth")
    There are cases where I have black bars, but I had that before on certain devices. The main difference is, now I don't have to offset my drawing because gideros changes my logical position. Nice!

    It still drives me crazy that the logicalDimensions are backwards when in landscape mode, but you can't have everything I guess.
Sign In or Register to comment.