Simulating a hook with Box2D
2009-10-18 00:00:00 来源:WEB开发网核心提示: Let’s see what I changed from the original scriptFirst, I changed GetBodyAtMouse function – lines 104-126 – so it only returns sta
Let’s see what I changed from the original script
First, I changed GetBodyAtMouse function – lines 104-126 – so it only returns static objects at line 116.
Then, I modified createMouse function – lines 90-97 – in order to create a joint between the center of the ball and the mouse position in the selected static object, and obviously the destroyMouse one to remove the joint when I release the mouse.
There isn’t much more to see that you can’t see in the posts I mentioned before.
Here it is the result:
Click on a static object (green) to create a joint on the fly
No need to include the source code, just replace the script at Box2D joints: Distance Joint with this one.
Tags:Simulating hook with
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接