旋转关节(Revolute Joint)

 1 package{
 2     import Box2D.Common.Math.b2Vec2;
 3     import Box2D.Dynamics.b2Body;
 4     import Box2D.Dynamics.Joints.b2RevoluteJointDef;
 5 
 6     /**
 7     * 旋转关节,指定刚体只能绕着某一个锚点旋转
 8     */
 9     public class Main extends BaseMain{
10         
11         
12         public function Main(){
13             super(new b2Vec2(0,10));
14         }
15         
16         override protected function init():void{
17             var bodyA:b2Body=this.createBox(50,50,400,300);
18             var bodyB:b2Body=this.createCircle(25,500,300);
19             bodyA.SetType(b2Body.b2_staticBody);
20             
21             var jointDef:b2RevoluteJointDef=new b2RevoluteJointDef();
22             var anchor:b2Vec2=bodyA.GetWorldCenter();
23             jointDef.Initialize(bodyA,bodyB,anchor);
24             _world.CreateJoint(jointDef);
25             
26         }
27         
28     };
29 }

旋转关节(Revolute Joint)_第1张图片

源码下载:http://yunpan.cn/c37q5HZxgp9M2  访问密码 69dd

你可能感兴趣的:(旋转关节(Revolute Joint))