Example usage for com.badlogic.gdx.physics.box2d World step

List of usage examples for com.badlogic.gdx.physics.box2d World step

Introduction

In this page you can find the example usage for com.badlogic.gdx.physics.box2d World step.

Prototype

public void step(float timeStep, int velocityIterations, int positionIterations) 

Source Link

Document

Take a time step.

Usage

From source file:com.jemge.box2d.Physics2D.java

License:Apache License

@Override
public void update() {
    for (World world : worlds.values()) {
        world.step(timeStep, velocityInteractions, positionInteractions);
    }/*from   w w  w.  j a v a2  s. com*/
}

From source file:com.nebula2d.scene.SceneManager.java

License:Open Source License

public static void fixedUpdate() {

    if (currentScene == null)
        return;/*from   w  w w.j a va  2  s. co m*/

    World physicalWorld = currentScene.getPhysicalWorld();
    physicalWorld.step(1 / 45f, 6, 2);

    Array<Body> bodies = new Array<Body>();
    physicalWorld.getBodies(bodies);

    for (Body body : bodies) {
        if (body.getType() != BodyDef.BodyType.StaticBody) {
            GameObject go = (GameObject) body.getUserData();
            go.setPosition(body.getPosition().x, body.getPosition().y);
            go.setRotation((float) (body.getAngle() * 180.0f / Math.PI));
        }
    }
}

From source file:loon.physics.PhysicsFixedWorld.java

License:Apache License

public void update(final float secondsElapsed) {

    this.pSecondsElapsedAccumulator += secondsElapsed;

    final int velocityIterations = this.pVelocityIterations;
    final int positionIterations = this.pPositionIterations;

    final World world = this.globalWorld;
    final float stepLength = this.pTimeStep;

    int stepsAllowed = this.pMaximumStepsPerUpdate;

    while (this.pSecondsElapsedAccumulator >= stepLength && stepsAllowed > 0) {
        world.step(stepLength, velocityIterations, positionIterations);
        this.pSecondsElapsedAccumulator -= stepLength;
        stepsAllowed--;/*from  w  w w .  ja  va2  s.c om*/
    }
    this.pPhysicsConnectorManager.update(secondsElapsed);
}