Touch.x/y

Get help using Construct 2

Post » Fri Jan 11, 2013 5:39 pm

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.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Fri Jan 11, 2013 9:44 pm

@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?



Many thanks for your help.kenhes2013-01-11 21:47:25
B
19
S
3
G
2
Posts: 212
Reputation: 4,011

Post » Fri Jan 11, 2013 11:35 pm

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.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Sat Jan 12, 2013 12:04 am

I'll give it a go. I assume the "on any touch end" is ok...
B
19
S
3
G
2
Posts: 212
Reputation: 4,011

Post » Tue Apr 16, 2013 6:47 am

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.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Wed Apr 17, 2013 3:21 pm

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:

Collidiumkenhes2013-04-17 15:22:19
B
19
S
3
G
2
Posts: 212
Reputation: 4,011

Post » Wed Apr 17, 2013 4:14 pm

Left Analog
var tid

OnTouch left analog
tid = -1
-- tid = touch.touchId

isTouch
tid = touch.touchID
-- do stuff

EndTouch
tid = touch.touchID
-- end stuff
-- tid = -1



I think I put up a link on the other thread Excal
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Previous

Return to How do I....?

Who is online

Users browsing this forum: Timedoor Indones and 23 guests