Hello everyone,
I have this simple question, yet I haven’t been able to solve it. I have created an object and applied physics to it. Also, when I tap it, I apply the applyLinearImpulse function like the following:
function moveBall (event)
ball:applylinearImpulse ( 0, -.2, event.x, event.y)
end
Runtime:addEventListener("tap", moveBall)
It all works fine. Now, I am trying to make it so that the ball bounces in the opposite direction of its tapped coordinates. Meaning, if you tap at the bottom of the object ( balloon in this case) it will go up, and if you tap the left side, it will go right…vice versa.
Any help will be highly appreciated.
Thanks.
[import]uid: 75258 topic_id: 26564 reply_id: 326564[/import]
When the user taps the balloon, you just compare the balloon’s “center” X/Y with the X/Y where the tap occurred. Then you can subtract the second pair of coordinates from the first pair, and apply a linear impulse to push it in the opposite direction.