本文整理汇总了Java中com.badlogic.gdx.math.MathUtils.ceil方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.ceil方法的具体用法?Java MathUtils.ceil怎么用?Java MathUtils.ceil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.MathUtils
的用法示例。
在下文中一共展示了MathUtils.ceil方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawMountain
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
private void drawMountain(SpriteBatch batch, float offsetX, float offsetY, float tintColor) {
TextureRegion reg = null;
batch.setColor(tintColor, tintColor, tintColor, 1);
float xRel = dimension.x * offsetX;
float yRel = dimension.y * offsetY;
//山区跨越整个关卡
int mountainLength = 0;
mountainLength += MathUtils.ceil(length / (2 * dimension.x));
mountainLength += MathUtils.ceil(0.5f + offsetX);
for (int i = 0; i < mountainLength; i++) {
// mountain left
reg = regMountainLeft;
batch.draw(reg.getTexture(), origin.x + xRel, position.y + origin.y
+ yRel, origin.x, origin.y, dimension.x, dimension.y,
scale.x, scale.y, rotation, reg.getRegionX(),
reg.getRegionY(), reg.getRegionWidth(),
reg.getRegionHeight(), false, false);
xRel += dimension.x;
// mountain right
reg = regMountainRight;
batch.draw(reg.getTexture(), origin.x + xRel, position.y + origin.y
+ yRel, origin.x, origin.y, dimension.x, dimension.y,
scale.x, scale.y, rotation, reg.getRegionX(),
reg.getRegionY(), reg.getRegionWidth(),
reg.getRegionHeight(), false, false);
xRel += dimension.x;
}
// reset color to white
batch.setColor(1, 1, 1, 1);
}
示例2: updateDesignResolutionSize
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
protected void updateDesignResolutionSize() {
if (_screenSize.width > 0 && _screenSize.height > 0
&& _designResolutionSize.width > 0 && _designResolutionSize.height > 0) {
_scaleX = (float)_screenSize.width / _designResolutionSize.width;
_scaleY = (float)_screenSize.height / _designResolutionSize.height;
System.out.println("policy = " + _resolutionPolicy);
if (_resolutionPolicy == ResolutionPolicy.NO_BORDER) {
_scaleX = _scaleY = _scaleX > _scaleY ? _scaleX : _scaleY;//MAX(_scaleX, _scaleY);
} else if (_resolutionPolicy == ResolutionPolicy.SHOW_ALL) {
_scaleX = _scaleY = _scaleX < _scaleY ? _scaleX : _scaleY;//MIN(_scaleX, _scaleY);
} else if ( _resolutionPolicy == ResolutionPolicy.FIXED_HEIGHT) {
_scaleX = _scaleY;
_designResolutionSize.width = MathUtils.ceil(_screenSize.width/_scaleX);
} else if ( _resolutionPolicy == ResolutionPolicy.FIXED_WIDTH) {
_scaleY = _scaleX;
_designResolutionSize.height = MathUtils.ceil(_screenSize.height/_scaleY);
}
// calculate the rect of viewport
float viewPortW = _designResolutionSize.width * _scaleX;
float viewPortH = _designResolutionSize.height * _scaleY;
// System.out.println("_designResolutionSize = " + _designResolutionSize);
// System.out.println(_scaleX + ", " + _scaleY);
// System.out.println("screen = " + _screenSize);
// System.out.println(viewPortW + ", " + viewPortH);
_viewPortRect.setRect((_screenSize.width - viewPortW) / 2, (_screenSize.height - viewPortH) / 2, viewPortW, viewPortH);
// System.out.println("updateDesignResolutionSize.viewport " + _viewPortRect);
// reset director's member variables to fit visible rect
Director director = Director.getInstance();
// System.out.println("design = " + _designResolutionSize);
director._winSizeInPoints.set(_designResolutionSize);
// getDesignResolutionSize()
director._isStatusLabelUpdated = true;
director.setProjection(director.getProjection());
//TODO debug >>>>>>
// setViewPortInPoints(_viewPortRect.x, _viewPortRect.y, _viewPortRect.width, _viewPortRect.height);
//show info
StringBuffer sb = new StringBuffer();
sb.append("glviewinfo >> \n resolutionPolicy = ").append(_resolutionPolicy).append('\n');
sb.append(" screen = ").append(_screenSize).append('\n');
sb.append(" designResolution = ").append(_designResolutionSize).append('\n');
sb.append(" viewPortRect = ").append(_viewPortRect).append('\n');
sb.append(" visibleRect = ").append(getVisibleRect()).append('\n');
sb.append(" scale = {").append(_scaleX).append(", ").append(_scaleY).append("}\n");
CCLog.engine(TAG, sb.toString());
}
}
示例3: nanosToSeconds
import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
private int nanosToSeconds(long nano) {
return MathUtils.ceil((float)(nano * NANOS_TO_SECONDS));
}