Incorrect Touch X, Y values on Android

0 favourites
  • 13 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hi,

    I am getting incorrect Touch X, Y values on Samsung S Advance Android phone. Same code works on desktop using Mouse.X/Y but on this device if I use Touch X, Y most of the time I get value as 0. What could be going wrong ?

    -Thanks

  • Have you tried to use Mouse.x("Layer") instead?

  • nothaseo

    He is talking about a touch problem, not mouse..

    mchulet

    I can assume it's a mistake on your events, so, if you can reproduce it on a CAPX we could help better.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There is a very simple explenation for this:

    touch.x and touch.y only have a value while touching. If your finger is not touching the screen the value will be 0

    Mouse.x and mouse.y however always have the value of where the mouse-pointer is regardless of if the button is clicked.

    So when making something for a touch device, you should always be aware that there is only input while touching.

  • TELLES0808 I'll try to clear the non-necessary things and post capx file.

    LittleStain I am checking for values after touch.

    -Thanks

  • ...

    So when making something for a touch device, you should always be aware that there is only input while touching.

    mchulet

    You said checking after and as LittleStain stated there is only input while touching

    so to workaround make an invisible sprite on touch at touch x,y then check values of the sprite after

  • DrGreenThumbCAN thats exactly my current approach, if you'd want to test please just print the Touch.X & Touch.Y on Sprite drag start and see that you'd get 0,0.

  • Works for me?

    Ok this wasn't on drag start..

    But you could ofcourse use on touch start instead..

    Combine on touch start with is dragging, maybe?

    Yep - touch start is dragging works..

  • mchulet,

    It sounds strange, I know, but on sprite drag start seems to (sometimes?) fire before on touch start. But the touch start is dragging example seems to work every time..

  • mchulet

    A good workaround is setup a global variable to save the last Touch position, like one variable for touch.x and another to touch.y

    Then, check the variable, and not the touch object.

    This is the way I'm doing for my game.

    goo.gl/1a3Jt

    On the game, open the chrome console, click inside the game and press D, it will show you the debug, where you can see the lastest touch position.

  • LittleStain Thanks, I'll try your solution.

    DrGreenThumbCAN these variable would need to be updated from value of Touch X, Y right ? if Touch does not carry proper values then won't these variable be reporting wrong values ?

    -Thanks

  • DrGreenThumbCAN these variable would need to be updated from value of Touch X, Y right ? if Touch does not carry proper values then won't these variable be reporting wrong values ?

    -Thanks

    mchulet

    Not sure what you mean

    but here's capxfor what I was meaning showing touch gives cor values

    mind you im using laptop dont have touch device but mouse is enabled as touch in properties by default (see manual)

    sorry maybe I don't understand your problem as I don't have touch device

    Set your x and y values to the sprite not the touch each tick (or your time interval) set sprite x to touch x and sprite y to touch y

    then when touch LEAVES sprite STAYS so values are staying as sprite is staying

    just make a small sprite and ot visible

  • Thanks DrGreenThumbCAN

    I think as a system its working fine, something that I have done that's making it mess up. Let me investigate.

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