本文整理汇总了Java中com.badlogic.gdx.math.MathUtils.degreesToRadians方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.degreesToRadians方法的具体用法?Java MathUtils.degreesToRadians怎么用?Java MathUtils.degreesToRadians使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.MathUtils
的用法示例。
在下文中一共展示了MathUtils.degreesToRadians方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
@Override
public void update() {
super.update(Utils.delta());
super.update();
// Get rotation depending on direction
if (direction == Direction.STRAIGHT) {
if (spriteRotation < ANGLE_DELTA_TOLERANCE && spriteRotation > - ANGLE_DELTA_TOLERANCE) spriteRotation = 0f;
if (spriteRotation < 0 * MathUtils.degreesToRadians)
spriteRotation += (ANGLE_DELTA * MathUtils.degreesToRadians) * Utils.delta();
else if (spriteRotation > 0 * MathUtils.degreesToRadians)
spriteRotation -= (ANGLE_DELTA * MathUtils.degreesToRadians) * Utils.delta();
velocity.y = 0;
} else if (direction == Direction.RIGHT) {
if (spriteRotation < TARGET_ANGLE * MathUtils.degreesToRadians)
spriteRotation += (ANGLE_DELTA * MathUtils.degreesToRadians) * Utils.delta();
velocity.setAngle(- 180f);
velocity.x -= velocity.x * 2;
velocity.y = 0;
} else if (direction == Direction.LEFT) {
if (spriteRotation > - TARGET_ANGLE * MathUtils.degreesToRadians)
spriteRotation -= (ANGLE_DELTA * MathUtils.degreesToRadians) * Utils.delta();
velocity.setAngle(180f);
velocity.x += velocity.x * 2;
velocity.y = 0;
}
// Check and block out-of-bounds movement
if (getX() < 0) setX(0);
if (getX() > Gdx.graphics.getWidth() - PLAYER_TEXTURE.getWidth()) setX(Gdx.graphics.getWidth() - PLAYER_TEXTURE.getWidth());
// Add/sub speed decay
if (velocity.len() > 0) velocity.setLength(velocity.len() - 15f);
else velocity.setLength(velocity.len() + 15f);
// Update texture
if (state == DrawState.IDLE) {
currentTexture.setTexture(PLAYER_TEXTURE);
} else if (state == DrawState.MOVING) {
currentTexture.setTexture(MOVING_PLAYER_TEXTURE);
} else if (state == DrawState.FIRING) {
currentTexture.setTexture(FIRING_PLAYER_TEXTURE);
} else if (state == DrawState.FIRING_MOVING) {
currentTexture.setTexture(MOVING_FIRING_PLAYER_TEXTURE);
}
// Update texture
currentTexture.setPosition(getX(), getY());
currentTexture.setRotation(- spriteRotation * MathUtils.radiansToDegrees);
// Rotate bounds
bounds.setRotation(- spriteRotation * MathUtils.radiansToDegrees);
}