当前位置: 首页>>代码示例>>Java>>正文


Java MathUtils.radDeg方法代码示例

本文整理汇总了Java中com.badlogic.gdx.math.MathUtils.radDeg方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.radDeg方法的具体用法?Java MathUtils.radDeg怎么用?Java MathUtils.radDeg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.math.MathUtils的用法示例。


在下文中一共展示了MathUtils.radDeg方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: angleToNext

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
private float angleToNext(int index) {
    Tile current = path.get(index);
    Tile next = path.get(index + 1);
    float dX = current.getX(Align.center) - next.getX(Align.center);
    float dY = current.getY(Align.center) - next.getY(Align.center);
    return MathUtils.atan2(dY, dX) * MathUtils.radDeg;
}
 
开发者ID:conquest,项目名称:conquest,代码行数:8,代码来源:Troop.java

示例2: updateFromEntities

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
public void updateFromEntities(Array<Entity> entities) {
    // if the game is not running don't update the physics
    if (mIsPaused) {
        return;
    }

    GravityComponent gravityComponent = mEngine.getComponentFromFirstEntity(
            GravityEntity.class, GravityComponent.class);
    if (gravityComponent != null) {
        Vector2 gravity = new Vector2(gravityComponent.normalisedGravity);
        mWorld.setGravity(gravity.scl(BASE_GRAVITY));
    }

    // update object position
    for (Entity entity : entities) {
        PhysicsComponent physicsComp = entity.getComponentByType(PhysicsComponent.class);
        PositionComponent positionComp = entity.getComponentByType(PositionComponent.class);
        RotationComponent rotationComp = entity.getComponentByType(RotationComponent.class);

        if (physicsComp == null) {
            continue;
        }

        if (positionComp != null) {
            positionComp.position.set(physicsComp.body.getPosition());
        }

        if (rotationComp != null) {
            rotationComp.degree = physicsComp.body.getAngle() * MathUtils.radDeg;
        }
    }

    // some constants taken from documentation, could be tweaked
    final float timeStep = 1.f / 45.f;
    final int velocityIterations = 6;
    final int positionIterations = 2;

    float deltaTime = Gdx.graphics.getDeltaTime();

    // fixed time step
    // max frame time to avoid spiral of death (on slow devices)
    float frameTime = Math.min(deltaTime, 0.25f);
    mAccumulator += frameTime;
    while (mAccumulator >= timeStep) {
        mWorld.step(timeStep, velocityIterations, positionIterations);
        mAccumulator -= timeStep;
    }
}
 
开发者ID:tgobbens,项目名称:fluffybalance,代码行数:49,代码来源:PhysicsSystem.java


注:本文中的com.badlogic.gdx.math.MathUtils.radDeg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。