本文整理汇总了Java中com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType类的典型用法代码示例。如果您正苦于以下问题:Java ShapeType类的具体用法?Java ShapeType怎么用?Java ShapeType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ShapeType类属于com.badlogic.gdx.graphics.glutils.ShapeRenderer包,在下文中一共展示了ShapeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: popShapeCommandCell
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
final StructShapeCommand popShapeCommandCell() {
if(currShapePos >= shapeCommandQueues.size) {
return null;
}
stackCommand.clear();
stackCommand.drawType = (DrawType) shapeCommandQueues.get(currShapePos++);
stackCommand.color = (Color) shapeCommandQueues.get(currShapePos++);
// 如果color是null则使用默认颜色
if(stackCommand.color == null) {
stackCommand.color = getDisplayedColor();
}
stackCommand.shapeType = (ShapeType) shapeCommandQueues.get(currShapePos++);
stackCommand.borderWidth = (float) shapeCommandQueues.get(currShapePos++);
int dataLen = (int) shapeCommandQueues.get(currShapePos++);
for(int i = 0; i < dataLen; ++i) {
stackCommand.vertexArray.add((Float) shapeCommandQueues.get(currShapePos++));
}
return stackCommand;
}
示例2: draw
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
public void draw(SpriteBatch spriteBatch) {
// Draw HUD Element if it needs to be drawn
if (showHUDElement) {
shapeRenderer.begin(ShapeType.Filled);
// Change HP color to yellow between 20% and 10% and red at 10% and lower
if (healthLeft >= (totalHealth * 0.4)) {
healthBarColor = Color.GREEN;
}
else if (healthLeft < (totalHealth * 0.4) && healthLeft > (totalHealth * 0.2)) {
healthBarColor = Color.YELLOW;
} else if (healthLeft < (totalHealth * 0.2)) {
healthBarColor = Color.RED;
}
shapeRenderer.setColor(healthBarColor);
shapeRenderer.rect(x, y, healthLeft - 1, height);
shapeRenderer.end();
shapeRenderer.begin(ShapeType.Line);
shapeRenderer.setColor(Color.WHITE);
shapeRenderer.rect(x, y, width, height);
shapeRenderer.end();
}
}
示例3: drawPolygonOutline
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
/**
* Internal method.
*
* <p>Implements drawing the outline of an open and
* closed polygon outline.</p>
*
* @see #drawPolygon(float, float...)
* @see #drawOpenPolygon(float, float...)
*/
private void drawPolygonOutline(float lineThickness, boolean close, float... points) {
if (points.length < 6) {
return; // Won't draw anything; does not have at least 3 edges.
}
if (points.length % 2 != 0) {
throw new IllegalArgumentException("uneven point");
}
this.startDrawingShape();
if (renderer.getCurrentType() != ShapeType.Filled) {
renderer.set(ShapeType.Filled);
}
for (int i = 2; i < points.length; i++) {
if (i % 2 == 0) {
this.drawLine(points[i - 2], points[i - 1], points[i], points[i + 1],
lineThickness);
}
}
if (close)
this.drawLine(points[points.length - 2], points[points.length - 1], points[0],
points[1], lineThickness);
}
示例4: renderSelectionRectangle
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
/**
* Draws the selection rectangle using the supplied renderer if selection is
* currently in progress.
*
* @param renderer
*/
private void renderSelectionRectangle() {
Rectangle selection = gameState.getPlayerCharacterController()
.getSelectionRectangle();
if (selection != null
&& Math.abs(selection.getHeight()) > Configuration
.getSelectionTolerance()
&& Math.abs(selection.getWidth()) > Configuration
.getSelectionTolerance()) {
// need to call the setter to make sure the matrix gets marked as dirty
shapeRenderer.setProjectionMatrix(shapeRenderer
.getProjectionMatrix().setToOrtho2D(0, 0,
Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));
shapeRenderer.begin(ShapeType.Line);
shapeRenderer.setColor(Color.GREEN);
shapeRenderer.rect(selection.x, selection.y, selection.width,
selection.height);
shapeRenderer.end();
}
}
示例5: renderGrid
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
private void renderGrid() {
shapeRenderer.setColor(Color.PINK);
shapeRenderer.begin(ShapeType.Line);
int halfArea = 200;
float width = viewport.getWorldWidth();
float height = viewport.getWorldHeight();
shapeRenderer.line(-width * halfArea, 0.0f, width * halfArea, 0.0f);
shapeRenderer.line(0.0f, -height * halfArea, 0.0f, height * halfArea);
shapeRenderer.setColor(Color.WHITE);
for (int i = -halfArea; i < halfArea; ++i) {
if (i == 0) continue;
shapeRenderer.line(-width * halfArea, i, width * halfArea, i);
shapeRenderer.line(i, -height * halfArea, i, height * halfArea);
}
shapeRenderer.end();
}
示例6: renderCameraDebug
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
private void renderCameraDebug() {
shapeRenderer.setProjectionMatrix(viewport.getCamera().combined);
shapeRenderer.setColor(Color.YELLOW);
shapeRenderer.begin(ShapeType.Line);
shapeRenderer.rect(
cameraFocusRect.x,
cameraFocusRect.y,
cameraFocusRect.width,
cameraFocusRect.height
);
shapeRenderer.setColor(Color.RED);
shapeRenderer.rect(
cameraTarget.x - 0.05f,
cameraTarget.y - 0.05f,
0.1f,
0.1f
);
shapeRenderer.end();
}
示例7: draw
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
@Override
public void draw() {
super.draw();
if(boss != null) {
renderer.begin();
moonImpactMeter.draw(renderer);
renderer.end();
}
if(isStageClear()) {
Gdx.gl.glEnable(GL20.GL_BLEND);
renderer.begin(ShapeType.Filled);
renderer.setColor(screenFadeActor.getColor());
renderer.rect(screenFadeActor.getX(), screenFadeActor.getY(), screenFadeActor.getWidth(), screenFadeActor.getHeight());
renderer.end();
Gdx.gl.glDisable(GL20.GL_BLEND);
}
if(debug) {
uiBatch.begin();
font.draw(uiBatch, screenLogger.toString(), 50, 300);
screenLogger.setLength(0);
uiBatch.end();
}
}
示例8: draw
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
public void draw(SpriteBatch batch) {
renderer.setAutoShapeType(true);
renderer.begin();
renderer.setColor(Color.WHITE);
for (int i = 0; i < map.length; i++) {
for (int j = map[0].length - 1; j >= 0; j--) {
renderer.set(filled[i][j] ? ShapeType.Filled : ShapeType.Line);
renderer.setColor(filled[i][j] ? Color.WHITE : Color.GRAY);
renderer.rect(i * sz + 50, j * sz + 50, sz, sz);
}
}
renderer.set(ShapeType.Filled);
renderer.setColor(Color.GREEN);
renderer.rect(entrance.x * sz + 50, entrance.y * sz + 50, sz, sz);
renderer.setColor(Color.YELLOW);
renderer.rect(exit.x * sz + 50, exit.y * sz + 50, sz, sz);
renderer.end();
}
示例9: render
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
public void render(ShapeRenderer renderer) {
renderer.setColor(Constants.PLAYER_COLOR);
renderer.set(ShapeType.Filled);
renderer.circle(position.x, position.y, Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_HEAD_SEGMENTS);
Vector2 torsoTop = new Vector2(position.x, position.y - Constants.PLAYER_HEAD_RADIUS);
Vector2 torsoBottom = new Vector2(torsoTop.x, torsoTop.y - 2 * Constants.PLAYER_HEAD_RADIUS);
renderer.rectLine(torsoTop, torsoBottom, Constants.PLAYER_LIMB_WIDTH);
renderer.rectLine(
torsoTop.x, torsoTop.y,
torsoTop.x + Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
renderer.rectLine(
torsoTop.x, torsoTop.y,
torsoTop.x - Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
renderer.rectLine(
torsoBottom.x, torsoBottom.y,
torsoBottom.x + Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
renderer.rectLine(
torsoBottom.x, torsoBottom.y,
torsoBottom.x - Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
}
示例10: renderPlayerData
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
public void renderPlayerData() {
game.spriteBatch.begin();
game.scoreFont.setColor(Color.WHITE);
game.scoreFont.draw(game.spriteBatch, "Score: " + Data.SCORE, 600, 500);
game.scoreFont.draw(game.spriteBatch, "Coins collected: "
+ Data.COINS_COLLECTED, 450, 500);
game.spriteBatch.end();
game.healthBar.setAutoShapeType(true);
game.healthBar.begin();
game.healthBar.set(ShapeType.Filled);
game.healthBar.setColor(Color.WHITE);
game.healthBar.rect(90, 465, 210, 40);
game.healthBar.setColor(Color.RED);
game.healthBar.rect(100, 470, Life.health * 2, 30);
game.healthBar.end();
}
示例11: render
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
game.spriteBatch.begin();
game.scoreFont.setColor(Color.WHITE);
game.scoreFont.draw(game.spriteBatch, "Player Name (Touch to Change)",
50, 320);
game.scoreFont.draw(game.spriteBatch,
"Music Settings (Touch to Change)", 50, 370);
game.spriteBatch.end();
game.healthBar.setAutoShapeType(true);
game.healthBar.begin();
game.healthBar.setColor(Color.RED);
game.healthBar.set(ShapeType.Filled);
game.healthBar.rect(280, 300, 150, 30);
game.healthBar.rect(280, 350, 150, 30);
game.healthBar.end();
act(delta);
draw();
}
示例12: render
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
@Override
public void render(float delta) {
// TODO: Update Icicles
icicles.update(delta);
player.update(delta);
iciclesViewport.apply(true);
Gdx.gl.glClearColor(Constants.BACKGROUND_COLOR.r, Constants.BACKGROUND_COLOR.g, Constants.BACKGROUND_COLOR.b, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderer.setProjectionMatrix(iciclesViewport.getCamera().combined);
renderer.begin(ShapeType.Filled);
// TODO: Render Icicles
icicles.render(renderer);
player.render(renderer);
renderer.end();
}
示例13: render
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
@Override
public void render(float delta) {
// TODO: Call update() on player
iciclesViewport.apply(true);
Gdx.gl.glClearColor(Constants.BACKGROUND_COLOR.r, Constants.BACKGROUND_COLOR.g, Constants.BACKGROUND_COLOR.b, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderer.setProjectionMatrix(iciclesViewport.getCamera().combined);
renderer.begin(ShapeType.Filled);
renderer.setColor(Constants.ICICLE_COLOR);
icicle.render(renderer);
player.render(renderer);
renderer.end();
}
示例14: render
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
@Override
public void render(float delta) {
// TODO: Apply the viewport
iciclesViewport.apply(true);
// TODO: Clear the screen to the background color
Gdx.gl.glClearColor(Constants.BACKGROUND_COLOR.r, Constants.BACKGROUND_COLOR.g, Constants.BACKGROUND_COLOR.b, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// TODO: Set the ShapeRenderer's projection matrix
renderer.setProjectionMatrix(iciclesViewport.getCamera().combined);
// TODO: Draw the Icicle
renderer.begin(ShapeType.Filled);
icicle.render(renderer);
renderer.end();
}
示例15: render
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; //导入依赖的package包/类
@Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderer.begin(ShapeType.Filled);
// Head
renderer.circle(100, 100, 10);
renderer.end();
renderer.begin(ShapeType.Line);
// Torso
renderer.line(100, 50, 100, 100);
// Legs
renderer.line(85, 35, 100, 50);
renderer.line(115, 35, 100, 50);
// Arms
renderer.line(85, 70, 100, 85);
renderer.line(115, 70, 100, 85);
renderer.end();
}