本文整理汇总了Java中com.badlogic.gdx.math.MathUtils.round方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.round方法的具体用法?Java MathUtils.round怎么用?Java MathUtils.round使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.MathUtils
的用法示例。
在下文中一共展示了MathUtils.round方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
public void draw(SpriteBatch batch) {
// If we beat a new record, the cup color will linear interpolate to the high score color
cupColor.lerp(isNewRecord() ? Klooni.theme.highScore : Klooni.theme.currentScore, 0.05f);
batch.setColor(cupColor);
batch.draw(cupTexture, cupArea.x, cupArea.y, cupArea.width, cupArea.height);
int roundShown = MathUtils.round(shownScore);
if (roundShown != currentScore) {
shownScore = Interpolation.linear.apply(shownScore, currentScore, 0.1f);
currentScoreLabel.setText(Integer.toString(MathUtils.round(shownScore)));
}
currentScoreLabel.setColor(Klooni.theme.currentScore);
currentScoreLabel.draw(batch, 1f);
highScoreLabel.setColor(Klooni.theme.highScore);
highScoreLabel.draw(batch, 1f);
}
示例2: putScreenPiece
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
public boolean putScreenPiece(final Piece piece) {
// Convert the on screen coordinates of the piece to the local-board-space coordinates
// This is done by subtracting the piece coordinates from the board coordinates
Vector2 local = piece.pos.cpy().sub(pos);
int x = MathUtils.round(local.x / piece.cellSize);
int y = MathUtils.round(local.y / piece.cellSize);
return putPiece(piece, x, y);
}
示例3: snapToGrid
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
Vector2 snapToGrid(final Piece piece, final Vector2 position) {
// Snaps the given position (e.g. mouse) to the grid,
// assuming piece wants to be put at the specified position.
// If the piece was not on the grid, the original position is returned
//
// Logic to determine the x and y is a copy-paste from putScreenPiece
final Vector2 local = position.cpy().sub(pos);
int x = MathUtils.round(local.x / piece.cellSize);
int y = MathUtils.round(local.y / piece.cellSize);
if (canPutPiece(piece, x, y))
return new Vector2(pos.x + x * piece.cellSize, pos.y + y * piece.cellSize);
else
return position;
}