How do I check Touch over object (as if collision)?

Get help using Construct 2

Post » Sun Mar 30, 2014 8:55 pm

Title should say it all. However, as having an object follow Touch.X and Touch.Y to detect collisions is laggy (the touch cursor lags behind). If I could detect Touch on collision with an object, that would be awesome. I have searched the forum for this data and cannot find anything related, or I do not know what I am searching for. Thank you!
B
27
S
7
G
6
Posts: 267
Reputation: 3,850

Post » Sun Mar 30, 2014 9:04 pm

I'm afraid I'm not sure I fully understand the problem you're having. To trigger the On Object Touched and Is Touching Object the Touch object already uses the object's collision polygon. So, touch on collision with an object is already instantly returned. The laggy cursor symptom you mention sounds interesting because the cursor must have been made using your own code - so this might be where your problem is... Have you got a capx you can post that shows the problem you're trying to fix?
A big fan of JavaScript.
B
76
S
20
G
74
Posts: 2,253
Reputation: 46,480

Post » Mon Mar 31, 2014 2:23 am

I mean when I touch something, I want to drag it elsewhere, and as it's dragging, while the touch x and y is over a new place, it should read from that object. but it can't be the sprite that does the detecting because if it's over two things then it's trying to do both, it has to be a 1x1 pixel perfect collision.
B
27
S
7
G
6
Posts: 267
Reputation: 3,850

Post » Mon Mar 31, 2014 2:48 am

Are you looking to drag a sprite and then check whether or not that sprite collides with another object? Or, are you looking to see if the touch.x and touch.y overlap a 2nd sprite whilst dragging a 1st sprite around?

A touch event can be detected by many different objects simultaneously, as long as those objects have collisions enabled.
A big fan of JavaScript.
B
76
S
20
G
74
Posts: 2,253
Reputation: 46,480

Post » Mon Mar 31, 2014 3:26 am

Yes, as soon as Touch.X and Touch.Y are overlapping an object while dragging, I need it to store the UID and various data about that object. I know there are other ways of doing this, but I didn't know if there were associated actions or if I have to be a little more savvy with coding it?
B
27
S
7
G
6
Posts: 267
Reputation: 3,850

Post » Mon Mar 31, 2014 11:03 am

I would add the objects you're interested in checking the touch for into a family with a family variable that is set as a different value for each sprite. Then while the touch is dragging, check for another touch event in the family - you can then use the family variable to filter which object was touched. Things like UID are then easy to get. Hope that helps.
A big fan of JavaScript.
B
76
S
20
G
74
Posts: 2,253
Reputation: 46,480

Post » Thu Apr 03, 2014 7:17 pm

This is the first post I've been able to find with someone talking about touch control and collision so I'm hoping someone can help with my similar problem. I have set up a game where you drag a character around the screen with your finger. I need walls to stop the movement of the character (like if he was going through a maze) but for the life of me I cannot figure out a way to do this. I'm new to using this program and so much of the collision detection in this engine seems to be set up with using Solids and then a movement behavior but controlling things with touch seems to completely ignore solids.

All I want is a way to stop the sprite's movement like it does using any of the other control types. I've tried using set position command to make the object bounce back a bit but if it collides, but it looks really janky and doesn't always work right. Any help that can be provided would be greatly appreciated.
B
4
Posts: 11
Reputation: 247


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 35 guests