Touch.x/y

  • I'm nearly finished my "hockey" game thanks to help from this forum. Just one last query. In the image, you'll see the green puck is being controlled by touch.x and touch.y. So it follows your finger when you move it around.

    But...if I add a second puck for a second finger, is that going to mess up the touch values on this one? And what if a player puts their palm down on the screen?

    <img src="https://dl.dropbox.com/u/10196246/Capture.JPG" border="0" />

  • Use On Nth Touch events. Dunno about the palm, but people should know how touch devices work so I would worry too much about that.

  • I tried that, but nth touch will only work if I use 0 as the value. Is it a bug? Maybe you could try it?

    Nth Touch

  • If the user puts the whole palm, nothing will happen, as mobile screens mostly recognize finger-touches.

  • 404

    I don't have a touch screen device so I wouldn't be able to test sorry.

  • Miyavi, ahh now I learned something new ;p

  • I just did. Being on my mobile desktop, with many icons, I did that, and none was triggered :P

  • Learning by accident. Awesome ;p

  • procrastinator Dropbox was taking ages to upload. It's working now. The green puck is set to nth touch 0 and works, but the red puck is set to 1 and doesn't.

    Nth Touch

  • You need to use the Touch id system and not Nth Touch :\ Nth Touch in the manual represents the NUMBER of fingers touching. So the Red puck will only work when the second finger is on the screen.

    To get a touchid

    --start of touch--

    onTouch(any puck)

    puck variable touchid = touch.touchid

    --move puck--

    puck var touchid > -1(keep in mind that touchid starts at 0)

    -> puck.xy = touch.XAtforID(puck.touchid)

    --release puck--

    on any touch end

    check for which touch was release and then find the puck

    you got the rest.

    For any multi touch control. You must use touchid references. Nth Touch is nearly worthless unless you are literally making a game about the sequence order of number of fingers actively on the screen.

  • jayderyu

    Great help thanks. Slowly getting there. :)

    I've implemented half of what you suggested and the pucks moves around as expected. See the image for the changes, but I don't exactly what you mean by these:

    --move puck--

    puck var touchid > -1(keep in mind that touchid starts at 0) Is this a condition?

    --release puck--

    check for which touch was release and then find the puck How to do this?

    <img src="https://dl.dropbox.com/u/10196246/multitouch.JPG" border="0" />

    Many thanks for your help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's notation for why it's listed as such.

    Also now that your using touchid.

    You can. remove variable puck.takingshot.

    Instead of the "is taking shot" and "is in touch" you can check to see if puck.tchID > -1

    instead of "setTakingShot to false". you can change to "set puck.tchID = -1" so that the value is removed and not compared.

    This will reduce your events and variables by 1. Since your using a form of on off variable with touchid. Might as reduce reduncencies.

    Good luck.

  • I'll give it a go. I assume the "on any touch end" is ok...

  • Hate to bump an old thread, but this is the same issue I'm having: how to get touchIDs for simultaneous events.

    kenhes, were you able to get a working solution? If so, can you share it? I find it unlikely that my other thread is going to get an answer since the majority of questions asked and answered here are more toward the beginner side.

  • I can't remember the exact process...it was trial and error. But I found a solution of sorts. Here's the project I used it on. It might get you going:

    Collidium

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