Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 844 Bytes

File metadata and controls

26 lines (19 loc) · 844 Bytes

Box2D PhysicsEditor XML Parser

A Java library for parsing XML files generated by PhysicsEditor into LibGDX's Box2D objects.

Usage

Here's an example for loading a body from src/test/resources/bugs.xml:

// you need a Box2D world to add the body to
World world = new World(new Vector2(0, -10), true);

// you'll need to create the body definition - PhysicsEditor doesn't support
// setting these attributes
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.DynamicBody;

// load the XML file
PEXML pexml = new PEXML(Gdx.files.internal("bugs.xml").file());

// create the body - this will also add it to the physics simulation
Body body = pexml.createBody("bug_0001", world, bodyDef, 1, 1);