How do I Adjust Touch coordinates while scaling layer?

0 favourites
  • 3 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Here is a gif, explaining what I mean.

    How do I adjust touch coordinates, to create these 4 colored blocks on correct positions considering the layer scale?

    Also, should I worry about long numbers like this one?

    How can I make it shorter? round() will round this number to 1 (because scaling takes value between 0, 1 and 2).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • UPDATE: I just realized you said layer scaling, not layout scaling, which my original info referred to. Refer to the manual entry for touch. X and Y don't adjust for layer scaling/rotation/what have you unless you give it a layer as a parameter. For example:

    Touch.X(0)
    Touch.Y(0)[/code:msahtfiz]
    Gives you adjusted touch coordinates for layer 0.
    
    As for the number length, you absolutely should not worry about that.  There's no extra work processing a high precision number like that vs. a rounded number, so long as internally they're stored as the same type(which they almost certainly are).
  • UPDATE: I just realized you said layer scaling, not layout scaling, which my original info referred to. Refer to the manual entry for touch. X and Y don't adjust for layer scaling/rotation/what have you unless you give it a layer as a parameter. For example:

    Touch.X(0)
    Touch.Y(0)[/code:2crfrhp9]
    Gives you adjusted touch coordinates for layer 0.
    
    As for the number length, you absolutely should not worry about that.  There's no extra work processing a high precision number like that vs. a rounded number, so long as internally they're stored as the same type(which they almost certainly are).
    

    Thanks alot!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)