I've written a simple game use Libgdx and Box2d. My main code here:
But when I rotate the big circle, the small circle still move normally as when I not rotate. It's look like the friction between 2 circle not affect. What I want is when rotate the big circle to the right (or left), the friction will pull the small circle follow too. Please help my. Thanks
Code: Select all
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.StaticBody;
bodyDef.position.set(new Vector2(mainGear.getX()
+ mainGear.getOriginX(), mainGear.getY()
+ mainGear.getOriginY()));
body = world.createBody(bodyDef);
float r = 231.5f;
Vector2[] vertexs = new Vector2[36];
for (int i = 0; i < 36; i++) {
vertexs[i] = new Vector2(MathUtils.cosDeg(10 * i) * r,
MathUtils.sinDeg(10 * i) * r);
}
ChainShape shape = new ChainShape();
shape.createLoop(vertexs);
FixtureDef fd = new FixtureDef();
fd.shape = shape;
fd.friction = 0.5f;
fd.density = 1;
body.createFixture(fd);
// Dynamic Body
BodyDef bodyDef1 = new BodyDef();
bodyDef1.type = BodyType.DynamicBody;
bodyDef1.position.set(200, 350);
body1 = world.createBody(bodyDef1);
CircleShape dynamicCircle = new CircleShape();
dynamicCircle.setRadius(16f);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = dynamicCircle;
fixtureDef.density = 1f;
fixtureDef.friction = 0.5f;
fixtureDef.restitution = 0.5f;
body1.createFixture(fixtureDef);
But when I rotate the big circle, the small circle still move normally as when I not rotate. It's look like the friction between 2 circle not affect. What I want is when rotate the big circle to the right (or left), the friction will pull the small circle follow too. Please help my. Thanks