一个具有多个圆形夹具的动态体减少了libgdx box2d中的fps

时间:2015-12-12 10:33:10

标签: libgdx box2d

// alpts is an array list of vector2 type

bodyDef.type=BodyType.DynamicBody;
bodyDef.position.set(0, 0);
Body body=world.createBody(bodyDef);
body.setUserData("chain");

for(int i=0;  i<alpts.size(); i++) {
      Vector2 vector=alpts.get(i);
      CircleShape shape=new CircleShape();
      shape.setRadius(.2f);
      shape.setPosition(vector);
      fixDef.shape=shape;
      fixDef.density=1;
      fixDef.friction=1f;
      fixDef.restitution=.5f;                 
     if(i>0) {
          Vector2 start=alpts.get(i-1);
          Vector2 end=alpts.get(i);                  
      }

      Fixture fixture=body.createFixture(fixDef);       

      String str="images/circle.png";
      MySprite sprite=new MySprite(makingTexture(str));
      sprite.setSize(.35f,.35f);
      sprite.setPosition(vector.x,vector.y);
      fixture.setUserData(sprite);                
      shape.dispose();
}
  1. 试图在触摸时制作一个带有许多圆形夹具的动态车身。
  2. 制作两个或三个身体后,每秒减少一帧。

0 个答案:

没有答案