How to swipe objects?

Hi all,
I’m currently thinking about the best way to handle swipes in combination with objects.
Try to imagine a game where you have to clean the screen from objects by swiping them out of the screen.
Direction should be simple by getting the action coordinates when pushed and released and the corresponding time stamps to get a swipe and not a drag and drop. But how to handle the game objects? They should response even if you start to swipe and hit a object midway. They should also accelerate in relation to the swipe.
I was thinking about doing these operations with coordinates only but I’m afraid that a object will only start moving when the swipe is finished. Any idea how to implement it with collision objects? Or is there even another way how to deal with it?

I think you can base this on my click and drag example but instead of having a requirement that the initial touch must be on top of the object to move you can also allow interaction while moving the finger/cursor. And when you detect a collision you move the object in the direction of movement of the cursor.

3 Likes

Thanks for the input @britzl !
The dragging works and while I was thinking about how to implement the “swipe” and giving the appropriate velocity to the go my cursor collided with, I found the contact_point_response message with the relative velocity feature. So my inital thought was to animate the swipped object with the relative velocity vector but in my tests the vector is always empty. I already made the cursor follow the input to have a real movement but the velocity vector stays at 0. Any idea why?

1 Like

Not sure why. But if you keep track of the previous touch point and a time stamp (use socket.gettime() for millisecond precision) you can easily calculate velocity.