Skip to content

Commit 8ffffed

Browse files
committed
updating chain example
1 parent bea253f commit 8ffffed

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

examples/box2d_Chain_RevoluteJoint/box2d_Chain_RevoluteJoint.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,10 @@ public void initScene() {
144144
}
145145

146146
{
147+
float seg = 1.5f;
148+
147149
PolygonShape shape = new PolygonShape();
148-
shape.setAsBox(0.6f, 0.225f);
150+
shape.setAsBox(seg/2, 0.225f);
149151

150152
FixtureDef fd = new FixtureDef();
151153
fd.shape = shape;
@@ -155,17 +157,18 @@ public void initScene() {
155157
RevoluteJointDef jd = new RevoluteJointDef();
156158
jd.collideConnected = false;
157159

158-
int count = 30;
159-
final float y = 25.0f;
160+
int count = 20;
161+
final float py = 25.0f;
162+
final float px = 5.0f;
160163
Body prevBody = ground;
161164
for (int i = 0; i < count; ++i) {
162165
BodyDef bd = new BodyDef();
163166
bd.type = BodyType.DYNAMIC;
164-
bd.position.set(0.5f + i, y);
167+
bd.position.set(px + i*seg + seg/2, py);
165168
Body body = world.createBody(bd);
166169
body.createFixture(fd);
167170

168-
Vec2 anchor = new Vec2(i, y);
171+
Vec2 anchor = new Vec2(px + i*seg, py);
169172
jd.initialize(prevBody, body, anchor);
170173
Joint joint = world.createJoint(jd);
171174

0 commit comments

Comments
 (0)