Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Screen Coordinates Off — Gideros Forum

Screen Coordinates Off

Daimyo21Daimyo21 Member
edited February 2014 in General questions
I have been developing my app on and off for 6+ months and in the past I have spent tons of hours playing around with the coordinates and looking at posts on these forums, trying to understand why my app does this but eventually just gave up and dealt with the annoying fact that my 0,0 coordinates virtually don't exist and pretty much way off.

Instead I've used methods such as Kredor7's to get around it: http://giderosmobile.com/forum/discussion/4321/easy-to-get-screen-edge-coordinates-regardless-of-screen-scaling/p1

self.widthDif = math.ceil(application:getLogicalTranslateX() / application:getLogicalScaleX())
self.heightDif = math.ceil(application:getLogicalTranslateY() / application:getLogicalScaleY())

My top left coordinates are (-200, 0) using method above. Though it doesnt really matter, it does get confusing at times when printing coordinates of sprite with getX(), getY(), getPosition() etc.

Here are my project properties:

Scale Mode: Letterbox

Logical dimensions 480w by 320h

Orientation Landscape Left

FPS 60


Anyone have an explanation/fix for this? Could it be sprites I am using etc?

Thanks!

Comments

  • You could try creating a function to process the coordinate value to take into account the extra screen space. This being just for the sake of showing it on screen as the platform its self would still be seeing it as -200,0.

    Likes: Daimyo21

    +1 -1 (+1 / -0 )Share on Facebook
  • You could try creating a function to process the coordinate value to take into account the extra screen space. This being just for the sake of showing it on screen as the platform its self would still be seeing it as -200,0.

    Yea I know what you mean, but why does it do this in the first place? is it like this for everyone? Also, how do people decide what base resolution they want to start their project at? I understand popular devices etc.

  • Yes it would be the same for everyone using the scaling modes. I believe its reason is for compatibility as if you places things at absolute positions say 100,100 on another scale this may be more to the right or left.

    With the scaling done this way it wont matter what scale/resolution everything will line up and you will get the letterbox effect (black bars, or image/colour if set).

    The way I see it is using the scaling is the easiest to use for most compatibility among devices. Harder method would be to use scaling but taking advantage of the extra pixels on certain devices. Example using the coords system you mentioned. The hardest way is no scaling at all and having to manually scale/position objects based on every screen size.

    As for what base resolution to start with it depends how much screen space you need. If you only need 480x320 to display everything you need with resonable size this would be the best to choose. (Just remember the higher base resolution devices will smaller screens wont be friendly)

    Likes: Daimyo21

    +1 -1 (+1 / -0 )Share on Facebook
  • @Daimyo21
    so you have a logical dimensions: 480w by 320h (although they should be vice versa 320x480, (in logical dimension smaller always comes first) but thats another topic)

    It means all your content must be prepared to deal with this dimensions.

    But hey, not all devices have this dimensions right, so how to make it look similar on 800x480? You scale it up.

    If the aspect ratio is the same (which is not the case in this situation as (480/320 = 1.5) and (800/480 = 1.66)) then you could simply scale up the scene with the one value for both width and height

    But what if the aspect ratio is different

    There are 3 ways to deal with it:
    1) Stretching
    We could stretch your width or height (what ever's ratio is larger) to fit the whole screen. This way 0,0 coordinate will always be in your left upper corner
    But stretching looks bad, so what are the other options?

    2) Cropping
    scale by center to fill whole screen and crop out other what goes outside the screen
    may not fit everyone but someone may use it.
    But should that mean that 0,0 coordinate should still be in left upper corner?
    No imagine if you position everything relative to the left uppoer, but then upscale it to fit whole screen, it would mean that cropping won't be centered, it would still be positioned relatively to upper left cropping everything on bottom right

    3) Letterbox
    Same goes for letter box. It upscales to the maximal dimension of width or height, which fills the screen first, leaving whitespaces on other dimension.
    And again if 0,0 cooridnate would be in top left corner and you position everything relatively to it, then it won't be centered. You would simple have large whitepsaces on bottom right sides.

    Thats why Gideros automatically changes the position of 0,0 on screen to comply with scaling mode being centered.

    Then the question remains how should you work with it.

    My suggestion would be, to prepare bigger BG graphics that go outside the screen (positioning them in the center of the screen using anchorpoint) and concentrate all the game on your logical dimensions.
    Here's an example:
    http://giderosmobile.com/forum/discussion/comment/13692#Comment_13692

    Work with desktop simulator set with your logical dimensions if that is better for your

    What if I want to position object in the corner completely
    Then as you did, ignore scaling by calculating the real offsets

    http://appcodingeasy.com/Gideros-Mobile/Ignore-Automatic-Screen-Scaling-when-positioning-objects

    Now if you want to work with 0,0 coordinates in your top left screen even with automatic scaling, you can try positioning a scene to these coordinates (-200, 0) in your case
    Then all children added to the scene will be positioned relatively to your corner, but as I said, that may lead to results that your game won't be centered. But if it would help you to understand the issue, try it ;)

    Hope that helps :)

    Likes: Daimyo21

    +1 -1 (+1 / -0 )Share on Facebook
  • Thanks guys, I truly appreciate the insight, Its been sort of a headache trying to figure out what background resolutions I was going to go with and what the final sizes were going to be coupled with the thought that I was doing it all wrong because of my coordinates being wacko.

    This helps tremendously with not only my confidence in what I've already been doing, but my understanding as well. I do have another problem that is related to sprites, grouping, and screen coordinates but I am going to play with it more, test some solutions, and also search for related issues to see if I can gauge the problem before asking help.

    Thanks again guys! ^:)^ :D
Sign In or Register to comment.