本文整理匯總了Java中com.badlogic.gdx.graphics.glutils.ShapeRenderer類的典型用法代碼示例。如果您正苦於以下問題:Java ShapeRenderer類的具體用法?Java ShapeRenderer怎麽用?Java ShapeRenderer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ShapeRenderer類屬於com.badlogic.gdx.graphics.glutils包,在下文中一共展示了ShapeRenderer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawMenu
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
private void drawMenu()
{
shapeRenderer.begin();
shapeRenderer.set(ShapeRenderer.ShapeType.Filled);
shapeRenderer.rect(Gdx.graphics.getWidth() - 80, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(),
Color.valueOf("#42f498"), Color.valueOf("#42f498"), Color.valueOf("#42f498"), Color.valueOf("#42f498"));
shapeRenderer.set(ShapeRenderer.ShapeType.Line);
shapeRenderer.line(Gdx.graphics.getWidth() - 80, 0, Gdx.graphics.getWidth() - 80, Gdx.graphics.getHeight(), Color.BLACK, Color.BLACK);
shapeRenderer.end();
batch.begin();
for(int i = 0; i < menuTextures.size(); i++)
{
batch.draw(menuTextures.get(i),
Gdx.graphics.getWidth() - 40 - menuTextures.get(i).getWidth()/2, Gdx.graphics.getHeight() - (menuTextures.get(i).getHeight() + MENU_PADDING_Y + i * 75),
menuTextures.get(i).getWidth(), menuTextures.get(i).getHeight());
}
batch.end();
}
示例2: drawBg
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
public void drawBg(Batch batch, float parentAlpha) {
batch.end();
Gdx.gl.glLineWidth(1.0f);
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
shapeRenderer.setProjectionMatrix(getStage().getCamera().combined);
Matrix4 matrix = batch.getTransformMatrix();
shapeRenderer.setTransformMatrix(matrix);
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
BG.a = parentAlpha;
shapeRenderer.setColor(BG);
shapeRenderer.rect(getX(), getY(), getWidth(), getHeight());
shapeRenderer.end();
Gdx.gl.glDisable(GL20.GL_BLEND);
batch.begin();
batch.setColor(Color.WHITE.r, Color.WHITE.g, Color.WHITE.b, Color.WHITE.a * parentAlpha);
}
示例3: GameObjectMap
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
GameObjectMap(AssetMap assetMap) {
this.assetMap = assetMap;
batch = new PolygonSpriteBatch();
shapeRenderer = new ShapeRenderer();
Pixmap pix = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
pix.setColor(Color.WHITE);
pix.fill();
texture = new Texture(pix);
regionMap = new HashMap<>();
regionNameMap = new HashMap<>();
initPolygonRegions();
}
示例4: draw
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
@Override
public void draw (Batch batch, float parentAlpha) {
batch.end();
Gdx.gl.glLineWidth(10);
for (PolygonRegion region : polygonRegions) {
this.batch.begin();
this.batch.draw(region, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
this.batch.end();
Polyline line = new Polyline(region.getVertices());
line.setScale(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());
shapeRenderer.setColor(Color.BROWN);
shapeRenderer.polyline(line.getTransformedVertices());
shapeRenderer.end();
}
batch.begin();
}
示例5: draw
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
public void draw(ShapeRenderer renderer) {
if (rect.width < 25 * cam.zoom || rect.height < 25 * cam.zoom) return;
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
renderer.setProjectionMatrix(cam.combined);
renderer.begin(ShapeRenderer.ShapeType.Filled);
renderer.setColor(new Color(0x228b2255));
renderer.rect(rect.x, rect.y, rect.width, rect.height);
renderer.set(ShapeRenderer.ShapeType.Line);
renderer.setColor(Color.BLACK);
renderer.rect(rect.x, rect.y, rect.width, rect.height);
renderer.end();
}
示例6: onInit
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
@Override
protected void onInit(ScreenBasedGame game, AssetManager assetManager) {
// generate fonts
this.font1 = BitmapFontFactory.createFont("./data/font/spartakus/SparTakus.ttf", 48, Color.WHITE, Color.BLUE,
3);
this.font2 = BitmapFontFactory.createFont("./data/font/spartakus/SparTakus.ttf", 48, Color.RED, Color.WHITE, 3);
// load & get assets
assetManager.load(TORPEDO_IMAGE_PATH, Texture.class);
assetManager.finishLoadingAsset(TORPEDO_IMAGE_PATH);
this.torpedoTexture = assetManager.get(TORPEDO_IMAGE_PATH, Texture.class);
// create new Head-Up-Display
this.hud = new HUD();
this.filledBar = new FilledBar(this.font1);
this.filledBar.setPosition(game.getViewportWidth() - 400, game.getViewportHeight() - 85);
this.filledBar.setDimension(155, 35);
this.hud.addWidget(this.filledBar);
this.shapeRenderer = new ShapeRenderer();
}
示例7: Crafting
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
public Crafting(int x, int y, int wid, int hei) {
this.x = x;
this.y = y;
this.wid = wid;
this.hei = hei;
shapes = new ShapeRenderer();
this.active = true;
fontHandler = new FontHandler();
layoutSave = new GlyphLayout(fontHandler.font32, "SAVE");
widthSave = layoutSave.width;
heightSave = layoutSave.height;
layoutExit = new GlyphLayout(fontHandler.font32, "X");
widthExit = layoutExit.width;
heightExit = layoutExit.height;
}
示例8: MainMenu
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
public MainMenu(JGame game) {
this.game = game;
this.batch = game.batch;
playY = (game.screenY / 2) + 200;
loadY = (game.screenY / 2) + 100;
exitY = (game.screenY / 2);
shapes = new ShapeRenderer();
fontHandler = new FontHandler();
layoutPlay = new GlyphLayout(fontHandler.font90, "PLAY");
widthPlay = layoutPlay.width;
heightPlay = layoutPlay.height;
layoutLoad = new GlyphLayout(fontHandler.font90, "LOAD");
widthLoad = layoutLoad.width;
heightLoad = layoutLoad.height;
layoutExit = new GlyphLayout(fontHandler.font90, "EXIT");
widthExit = layoutExit.width;
heightExit = layoutExit.height;
}
示例9: drawCollisionBoxes
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
public void drawCollisionBoxes(GameTime time, CameraWrapper camera, ShapeRenderer shapeRenderer, Color baseColor,
Color inCollisionColor) {
Color color = null;
if (alreadyInCollision) {
color = inCollisionColor;
} else {
color = baseColor;
}
// first, draw hull
if (this.hullShape != null) {
this.hullShape.drawShape(time, camera, shapeRenderer, color);
}
// draw inner shapes
for (CShape shape : this.collisionShapes) {
shape.drawShape(time, camera, shapeRenderer, color);
}
}
示例10: drawLayer1
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
@Override
public void drawLayer1(GameTime time, ShapeRenderer shapeRenderer) {
// draw background
shapeRenderer.setColor(this.backgroundColor);
shapeRenderer.rect(getX(), getY(), getWidth(), getHeight());
float maxWidth = getWidth() - (paddingLeft + paddingRight);
float maxHeight = getHeight() - (paddingTop + paddingBottom);
float barWidth = maxWidth * percent;
float barHeight = maxHeight;
// draw foreground
shapeRenderer.setColor(this.foregroundColor);
shapeRenderer.rect(getX() + paddingBottom, getY() + paddingLeft, barWidth, barHeight);
}
示例11: create
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
@Override
public void create() {
saveFile = Gdx.files.local("bin/saves.dat");
if (saveFile.exists()) {
load();
} else {
currentDescriptor = newSaveFileDescriptor();
save();
}
aspectRatio = (float) Gdx.graphics.getHeight() / (float) Gdx.graphics.getWidth();
batch = new SpriteBatch();
sr = new ShapeRenderer();
setCurrentScreen(new SplashScreen());
Gdx.graphics.requestRendering();
Gdx.input.setInputProcessor(this);
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); //fixes red screen bug on startup
Gdx.input.setCatchBackKey(true);
}
示例12: render
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
@Override
public void render(SpriteBatch sb, ShapeRenderer sr) {
sb.setProjectionMatrix(camera.combined);
sr.setAutoShapeType(true);
sr.setProjectionMatrix(camera.combined);
//SHAPERENDERER
sr.begin();
sr.set(ShapeRenderer.ShapeType.Filled);
sr.setColor(new Color(23 / 255f, 23 / 255f, 23 / 255f, 1f));
sr.rect(0, 0, Game.WIDTH, Game.HEIGHT);
for (int i = 0; i < background.length; i++) {
background[i].renderSR(sr);
}
play.renderSR(sr);
music.renderSR(sr);
sr.end();
//SPRITEBATCH
sb.begin();
sb.draw(logo, Game.WIDTH / 2 - (logo.getTexture().getWidth() * 10) / 2, Game.HEIGHT - 50 - logo.getHeight() * 10, logo.getWidth() * 10, logo.getHeight() * 10);
play.renderSB(sb);
music.renderSB(sb);
betaText.draw(sb, "Beta Release - Copyright 2017 Gussio. All rights reserved. Visit https://gussio.nl/ for more info.", 10, 25);
sb.end();
}
示例13: render
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
@Override
public void render(SpriteBatch sb, ShapeRenderer sr) {
sb.setProjectionMatrix(camera.combined);
sr.setAutoShapeType(true);
sr.setProjectionMatrix(camera.combined);
//BACKGROUND
sr.begin();
sr.set(ShapeRenderer.ShapeType.Filled);
sr.setColor(Color.WHITE);
sr.rect(0, 0, Game.WIDTH, Game.HEIGHT);
sr.end();
//LOGO
sb.begin();
sb.draw(logo, Game.WIDTH / 2 - logo.getWidth() * 20 / 2, Game.HEIGHT / 2 - logo.getHeight() * 20 / 2, logo.getWidth() * 20, logo.getHeight() * 20);
sb.end();
}
示例14: HudScene
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
public HudScene(SpriteBatch batch, ShapeRenderer shapeRenderer, ArcRenderer arcRenderer) {
this.batch = batch;
stage = new Stage();
VisUI.load();
Table table = new Table();
table.top();
table.setFillParent(true);
scoreLabel = new Label("", new Label.LabelStyle(new BitmapFont(), Color.VIOLET));
setScore(score);
balanceLabel = new Label("", new Label.LabelStyle(new BitmapFont(), Color.VIOLET));
setBalance(balance);
table.add(scoreLabel).align(Align.left).expandX();
table.add(balanceLabel).align(Align.right).expandX();
stage.addActor(table);
ringButton = new RingButton(shapeRenderer, arcRenderer);
ringButton.setBounds(10, 10, 100, 100);
stage.addActor(ringButton);
}
示例15: create
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //導入依賴的package包/類
@Override
public void create() {
if (androidInterface != null)
androidInterface.tryToStopMusicApp();
batch = new SpriteBatch();
sr = new ShapeRenderer();
camera = new OrthographicCamera();
viewport = new FitViewport(Configuration.WINDOW_WIDTH, Configuration.WINDOW_HEIGHT, camera);
camera.position.set(viewport.getWorldWidth() / 2 - (viewport.getWorldWidth() - 500) / 2, viewport.getWorldHeight() / 2 - (viewport.getWorldHeight() - 220) / 2, 0);
camera.update();
fade = new Sprite(new Texture("sprites/fade.png"));
fade.setBounds(0, -100, viewport.getWorldWidth(), viewport.getWorldHeight() - 40);
font = new BitmapFont(Gdx.files.internal("fonts/amiga4everpro2.fnt"));
showModernTimesCutscene(); // start the game
}