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


Java MathUtils.round方法代码示例

本文整理汇总了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);
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:19,代码来源:BaseScorer.java

示例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);
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:9,代码来源:Board.java

示例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;
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:15,代码来源:Board.java


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