Throw, toss, push body with mouse

Discuss issues specific to the Flash/AS3 port of Box2D
Posts: 1
Joined: Thu Dec 13, 2012 5:06 am

Throw, toss, push body with mouse

Postby gMirian » Thu Dec 13, 2012 5:26 am

I'm newbie here, please help.
Game is with view from above (zero gravity), I need to throw/toss circle body with mouse (it's table from above and coins on it).
I already set up world, create mouse joint, but what I need is: not allow somehow to just drag and drop circle with mouse, instead need circle to be tossed; so if mouse is down and user just drags circle item instead of throwing it to destroy mouse joint (while mouseMove, not waiting to mouseUp), or give notice that it's wrong move etc. I just can't realized how to detect user is throwing object or just dragging it, it's something like to guess if user did fast swipe gesture or not.
I tried several options:
Record body.GetLinearVelocity().Length(); and compare this on every mouse move to detect if mouse is accelerated or not, didn't helped
Get mouseDown, mouseUp time and somehow prevent this time period exceed some value (hard to guess what value to set)
Check trajectory of mouse to check if user is just tossing circle linearly, but this also didn't helped much.
Can you suggest solution how to do this?
Thanks in advance :)

irresistible force
Posts: 1991
Joined: Tue Jun 24, 2008 8:25 pm
Location: Tokyo

Re: Throw, toss, push body with mouse

Postby irresistible force » Fri Dec 14, 2012 9:52 pm

How about checking the linear velocity of the coin just before destroying the mouse joint in mouseUp?

Return to “Flash”

Who is online

Users browsing this forum: No registered users and 2 guests