swipe collison and velocity

Hi after trying out the ‘Samurai Fruit’ example code. I decided to change the control mechanism of my game.

I want to hit a block with a swipe. Is it possible to detect when a swipe first hits an object and would it be possible to detect it’s velocity?

As I’m using the physics engine I was thinking a solution would be creating a hidden object that gets dragged with the swipe.

Any ideas would be appreciated. [import]uid: 25939 topic_id: 10515 reply_id: 310515[/import]

My first thought was the same as yours, attach a hidden object to the touch that gets dragged around with your finger. I’m not sure if that’s the best solution tho, I haven’t looked at the samurai fruit example.

This article talks about how to get collision force info: http://developer.anscamobile.com/content/game-edition-collision-detection [import]uid: 48658 topic_id: 10515 reply_id: 38642[/import]

I haven’t looked into Samurai Fruits code yet either, but here is an alternative.

You can calculate the displacement in 2 successive touch event, and note time between them two calculate instantaneous velocity vector.

When your object gets a touch event, you can similarly calculate instantaneous velocity vector and apply linear impulse proportional to the velocity.

[import]uid: 48521 topic_id: 10515 reply_id: 38647[/import]

Thank you for your replies. In the end I just turned the line into a physics body before it gets remove and applied some force.

[lua]transition.to(line, {time = lineFadeTime, alpha = 0, width = 0, onComplete =
function(event) physics.addBody (line, {bounce = 0.0, friction = 1.0}) line:applyForce( 2.5, 0, event.x, event.y ) line:removeSelf() end})[/lua]

It may not be the best way of doing it but it will do for now. [import]uid: 25939 topic_id: 10515 reply_id: 38772[/import]