Java Code Examples for com.badlogic.gdx.math.Vector2.angle()

The following are Jave code examples for showing how to use angle() of the com.badlogic.gdx.math.Vector2 class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: SpaceChaos   File: MoveDependentDrawRotationComponent.java   Source Code and License Vote up 6 votes
@Override
public void update(BaseGame game, GameTime time) {
    // get move direction
    Vector2 moveDir = moveComponent.getMoveDirection();

    float angle = 0;

    if (moveComponent.isMoving()) {
        // get angle
        angle = moveDir.angle() - 90;
        this.lastAngle = angle;
    } else {
        angle = this.lastAngle;
    }

    frontVector.set(0, 1);
    frontVector.setLength(1);
    frontVector.setAngle(angle + 90);

    drawComponent.setRotationAngle(angle);
}