Multi-touch issue when testing 'is touching obj'

Get help using Construct 2

Post » Wed Jun 12, 2013 9:55 pm

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:


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!
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,644

Post » Thu Jun 13, 2013 7:17 pm

*Bump* This left the front page pretty quickly ;)
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,644

Post » Thu Jun 13, 2013 7:31 pm

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
Moderator
B
92
S
32
G
33
Posts: 3,005
Reputation: 27,582

Post » Thu Jun 13, 2013 9:22 pm

@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.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,644

Post » Fri Jun 14, 2013 12:47 am

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.Arima2013-06-14 00:48:07
Moderator
B
92
S
32
G
33
Posts: 3,005
Reputation: 27,582

Post » Mon Jun 17, 2013 4:26 pm

@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?
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,644

Post » Mon Jun 17, 2013 10:13 pm

Replace touch.touchindex with touch.touchid and touch.xat/touch.yat with touch.xforid/touch.yforid.
Moderator
B
92
S
32
G
33
Posts: 3,005
Reputation: 27,582


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], LaurenceBedford, legendaryarcane, Magistross, randomly and 10 guests