I found great tool to make shapes. But the example how to load the shape for javascript. He wrote
Note: the following code snippets are extracted from the loader-libgdx-demo project. They are written in Java, and target the LibGDX game framework. However, they should be easy to understand, and easy to port to any other language.
But I cannot find it easy at all :)
private void createBottle() {
// 0. Create a loader for the file saved from the editor.
BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal("data/test.json"));
// 1. Create a BodyDef, as usual.
BodyDef bd = new BodyDef();
bd.position.set(0, 0);
bd.type = BodyType.DynamicBody;
// 2. Create a FixtureDef, as usual.
FixtureDef fd = new FixtureDef();
fd.density = 1;
fd.friction = 0.5f;
fd.restitution = 0.3f;
// 3. Create a Body, as usual.
bottleModel = world.createBody(bd);
// 4. Create the body fixture automatically by using the loader.
loader.attachFixture(bottleModel, "test01", fd, BOTTLE_WIDTH);
}
So what to do with this line:
BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal("data/test.json"));
BodyEditorLoader should be in jar file. But javascript cannot use this. Or I have to open jar file itselt and recode in javascritp?
Or maybe there exists something like this for javascritpt?