public void render(OrthographicCamera camera) { // update the world with a fixed time step world.step(Gdx.app.getGraphics().getDeltaTime() * 10, 8, 3); if (mouseJoint != null) mouseJoint.setTarget(bob.getBody().getWorldCenter()); // Destroy mouseJoint? (drop item) if (destroyMousejoint == true) { if (!world.isLocked()) { world.destroyJoint(mouseJoint); mouseJoint = null; destroyMousejoint = false; } } // Delete any bodies up for deletion if (!bodiesToDelete.isEmpty()) { // Make sure it is safe to delete!! if (!world.isLocked()) { for (Body body : bodiesToDelete) { world.destroyBody(body); body.setUserData(null); body = null; } bodiesToDelete.clear(); // Don't forget to clear the null bodies! } } // Create any bodies up for creation if (!bodiesToCreate.isEmpty()) { // Make sure it is safe to create!! if (!world.isLocked()) { for (BodyDef body : bodiesToCreate) { world.createBody(body); } bodiesToCreate.clear(); // Don't forget to clear! } } // Create any joints up for creation if (!jointsToCreate.isEmpty()) { // Make sure it is safe to create!! if (!world.isLocked()) { for (JointDef body : jointsToCreate) { mouseJoint = (MouseJoint) world.createJoint(body); } jointsToCreate.clear(); // Don't forget to clear! } } // render the world using the debug renderer renderer.render(world, camera.combined); }
public void jumpBob(Vector2 jump) { bob.getBody().applyLinearImpulse(jump, bob.getBody().getWorldCenter(), true); }
// Bob-specific methods ************************************************************ public void moveBob(Vector2 direction) { bob.getBody().applyForceToCenter(direction, true); }