How do I get a specific touch index coordinates?

Get help using Construct 2

Post » Fri Jun 10, 2016 8:08 am



Thanks, because dpads are very small in general, so I wanted to extend the range of moving, by moving potentially all across the screen, once the user started touching the dpad.
B
18
S
7
G
1
Posts: 160
Reputation: 1,934

Post » Fri Jun 10, 2016 9:12 am

Your code in the OP is not valid since you only modify the TouchIndex value in the "On touched" event (which actually triggers once the touch is over and the user removed his finger).
In your case, you should rather set TouchIndex value in a "On any touch start" event.

Then in your event 2, in addition to "is touching", add the condition "Has Nth touch" where Nth value is TouchIndex as Newt was saying from the get go.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
294
S
117
G
96
Posts: 7,312
Reputation: 71,092

Post » Fri Jun 10, 2016 10:51 am

trueicecold wrote:
Thanks, because dpads are very small in general, so I wanted to extend the range of moving, by moving potentially all across the screen, once the user started touching the dpad.


Okay, this i understand, so you want the index of the touch when the dtap is tapped, set a boolean to know that it is tapped, and unset the boolean when that the touch of that index is taken away from the screen.

Als long as the boolean is set, the ship moves.

At the same time player can tap (or hold ?) anywhere on the screen to fire bullets.

I did not understand purpose of the events as showed in the first post.

I try to make a capx later, if no one else did it b4 me.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Jun 10, 2016 11:29 am

@Instances2Go, exactly. All is ok if I touch the dpad and move the ship and then touch the fire button.
Problem starts when I first click the fire button, and only then touch the dpad to make the ship move. I get very weird ship movement...
B
18
S
7
G
1
Posts: 160
Reputation: 1,934

Post » Fri Jun 10, 2016 11:34 am

@Kyratic, I think my problem resides in the fact that "is in touch" refers to ANY touch on the screen, and in its action, Touch.X will return the first Touch X, and not the one I really want to calculate from. so if I have 2 touches (first, the fire, then the dpad), there's no way for me to get Touches[1].X.
B
18
S
7
G
1
Posts: 160
Reputation: 1,934

Post » Fri Jun 10, 2016 4:54 pm

So... I changed TouchIndex to TouchID, since this is something you can get X and Y for (XForID(TouchIndex)). All works well now :)

Thanks for anyone who tried helped! :)
B
18
S
7
G
1
Posts: 160
Reputation: 1,934

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests