-
Notifications
You must be signed in to change notification settings - Fork 1
Physics
miguel edited this page May 13, 2019
·
3 revisions
This framework fully integrates with box2d and box2dlights:
Simply access the PhysicsManager via the GameContext
:
GameWorld gameWorld = context.getGameWorld();
GameObject gameObject = gameWorld.newGameObject();
PhysicsManager physicsManager = context.getPhysicsManager();
BodyDef bodyDef = new BodyDef(/* create body def here */);
FixtureDef fixtureDef = new FixtureDef(/* create FixtureDef here */);
physicsManager.attachBody(bodyDef, fixtureDef, gameObject);
First of all, we create a new game object. Afterwards we are defining a BodyDef and FixtureDef which describes the shape of the physics object as well as its physical properties. Then we simply attach it to the game object. At runtime, braingdx keeps care of updating the GameObject
respectively.