BodyEditorLoader loader = new BodyEditorLoader(
Gdx.files.internal("data/player.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;
但在第1行显示错误BodyEditorLoader未知,我不知道如何让它知道android studio。
答案 0 :(得分:0)
尝试将此类添加到您的项目中(尽管由于libGDX
API中的更改可能无法正常运行,但它应该相当容易使用):
答案 1 :(得分:0)
三个简单的步骤:
- 创建正文编辑器
醇>
BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal(“data / player.json”));
- 创建身体定义,然后使用物理世界中的def创建身体。
醇>
BodyDef bdef = new BodyDef();
bdef.position.set(0,0);
bdef.type = BodyDef.BodyType.DynamicBody;
Body body = world.createBody(bdef);
- 创建夹具定义并附加到正文
醇>
FixtureDef fdef = new FixtureDef();
fdef.density = 1;
fdef.friction = 0.5f;
fdef.restitution = 0.5f;
float scale =.1f;
loader.attachFixture(body, "Name", fdef, scale);