本文整理汇总了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;
}
示例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;
}
}