// 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();
}
- 试图在触摸时制作一个带有许多圆形夹具的动态车身。
- 制作两个或三个身体后,每秒减少一帧。
醇>