Touch.x/y

Get help using Construct 2

Post » Fri Jan 11, 2013 12:19 am

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?

B
19
S
3
G
2
Posts: 212
Reputation: 4,011

Post » Fri Jan 11, 2013 12:24 am

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.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Jan 11, 2013 2:59 am

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
B
19
S
3
G
2
Posts: 212
Reputation: 4,011

Post » Fri Jan 11, 2013 3:02 am

If the user puts the whole palm, nothing will happen, as mobile screens mostly recognize finger-touches.
B
6
Posts: 54
Reputation: 808

Post » Fri Jan 11, 2013 3:03 am

404

I don't have a touch screen device so I wouldn't be able to test sorry.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Jan 11, 2013 3:03 am

@miyavi, ahh now I learned something new ;pprocrastinator2013-01-11 03:04:08
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Jan 11, 2013 3:04 am

I just did. Being on my mobile desktop, with many icons, I did that, and none was triggered :P
B
6
Posts: 54
Reputation: 808

Post » Fri Jan 11, 2013 3:11 am

Learning by accident. Awesome ;p
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Jan 11, 2013 2:41 pm

@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 Touchkenhes2013-01-11 14:42:04
B
19
S
3
G
2
Posts: 212
Reputation: 4,011

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

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests