Multi-touch issue when testing 'is touching obj'

0 favourites
  • 7 posts
From the Asset Store
Buildings - Isometric view - PNG transparent - multi styles, multi fonctions buildings
  • Hey all,

    I've been trying to implement Multi-touch in a game for a client. Basically, one finger is used to aim a turret, while the other presses various fire buttons.

    Here's my code:

    <img src="http://i.imgur.com/9XCKY4x.png" border="0" />

    The problem lies in event 326. Basically, you'd think the "Is not touching GameButtons" conditions should only apply to the touch I'm picking for the event. However, it seems to use it like a global statement - i.e. it will return true if any touch is touching a GameButton.

    Does anyone know a way around this? How can I tell if this touch is touching a GameButton or not, as opposed to any touch?

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • *Bump* This left the front page pretty quickly ;)

  • How I did it was to make a sprite for touches, so on touch it gets placed, gets the touch id, etc. then I check distance to a button or collisions with those instead of using the built in 'is touching object' condition.

    So like:

    On any touch start

    If touchsprite.touchid=0

    Pick one touchsprite at random

    • set touchsprite.touchuid to touch.touchuid <-- can't remember the actual expression name ATM
    • set touchsprite position to touch xy

    Sub event

    If touchsprite is overlapping object

    • do stuff
  • Arima I think I see what you mean, however I'm having trouble destroying the sprites - if I use 'on any touch end' it destroys all of them, not just one.

  • I don't destroy them, I simply set the touchsprite.touchuid variable to 0 like so:

    On touch end

    touchsprite.touchid=touch.touchuid

    • set touchsprite.touchuid to 0

    Though I suppose destroying them might work if they're still picked correctly, I haven't tried it.

  • Arima

    I've been playing around with it for a few days. I can't really seem to find a solution - the problem lies with the 'on any touch end' condition.

    Here's a simple capx that shows the issue.

    You'll see that, often when you have two fingers pressed to the screen and release one, both TouchSprites are destroyed.

    Any tips?

  • Replace touch.touchindex with touch.touchid and touch.xat/touch.yat with touch.xforid/touch.yforid.

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