Java Code Examples for com.badlogic.gdx.graphics.g2d.SpriteBatch#end()
The following examples show how to use
com.badlogic.gdx.graphics.g2d.SpriteBatch#end() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GigaGalHud.java From ud406 with MIT License | 6 votes |
public void render(SpriteBatch batch, int lives, int ammo, int score) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); final String hudString = Constants.HUD_SCORE_LABEL + score + "\n" + Constants.HUD_AMMO_LABEL + ammo; font.draw(batch, hudString, Constants.HUD_MARGIN, viewport.getWorldHeight() - Constants.HUD_MARGIN); final TextureRegion standingRight = Assets.instance.gigaGalAssets.standingRight; for (int i = 1; i <= lives; i++) { final Vector2 drawPosition = new Vector2( viewport.getWorldWidth() - i * (Constants.HUD_MARGIN / 2 + standingRight.getRegionWidth()), viewport.getWorldHeight() - Constants.HUD_MARGIN - standingRight.getRegionHeight() ); Utils.drawTextureRegion( batch, standingRight, drawPosition ); } batch.end(); }
Example 2
Source File: GameOverOverlay.java From ud406 with MIT License | 6 votes |
public void render(SpriteBatch batch) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); // TODO: Draw a game over message // Feel free to get more creative with this screen. Perhaps you could cover the screen in enemy robots? float timeElapsed = Utils.secondsSince(startTime); int enemiesToShow = (int) (Constants.ENEMY_COUNT * (timeElapsed / Constants.LEVEL_END_DURATION)); for (int i = 0; i < enemiesToShow; i++){ Enemy enemy = enemies.get(i); enemy.update(0); enemy.render(batch); } font.draw(batch, Constants.GAME_OVER_MESSAGE, viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 2.5f, 0, Align.center, false); batch.end(); }
Example 3
Source File: NavMeshDebugDrawer.java From GdxDemo3D with Apache License 2.0 | 6 votes |
private void drawNavMeshIndices(SpriteBatch spriteBatch, Camera camera, BitmapFont font) { // TODO: Get rid of all the transform matrix setting if (spriteBatch.isDrawing()) { spriteBatch.end(); } spriteBatch.begin(); spriteBatch.setProjectionMatrix(camera.combined); for (int i = 0; i < navMesh.graph.getNodeCount(); i++) { Triangle t = navMesh.graph.getTriangleFromGraphIndex(i); if (triangleIsVisible(t)) { tmpMatrix.set(camera.view).inv().getRotation(tmpQuat); tmpMatrix.setToTranslation(t.centroid).rotate(tmpQuat); spriteBatch.setTransformMatrix(tmpMatrix); font.draw(spriteBatch, Integer.toString(t.triIndex), 0, 0); } } spriteBatch.end(); }
Example 4
Source File: GigaGalHud.java From ud406 with MIT License | 6 votes |
public void render(SpriteBatch batch, int lives, int ammo, int score) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); final String hudString = Constants.HUD_SCORE_LABEL + score + "\n" + Constants.HUD_AMMO_LABEL + ammo; font.draw(batch, hudString, Constants.HUD_MARGIN, viewport.getWorldHeight() - Constants.HUD_MARGIN); final TextureRegion standingRight = Assets.instance.gigaGalAssets.standingRight; for (int i = 1; i <= lives; i++) { final Vector2 drawPosition = new Vector2( viewport.getWorldWidth() - i * (Constants.HUD_MARGIN / 2 + standingRight.getRegionWidth()), viewport.getWorldHeight() - Constants.HUD_MARGIN - standingRight.getRegionHeight() ); Utils.drawTextureRegion( batch, standingRight, drawPosition ); } batch.end(); }
Example 5
Source File: CraftingScreen.java From TerraLegion with MIT License | 6 votes |
@Override public void render(SpriteBatch sb) { sb.setProjectionMatrix(camera.combined); sb.begin(); sb.draw(bg, 0, 0); itemNameLabel.render(sb); itemInfoLabel.render(sb); cancelBtn.render(sb); craftingBtn.render(sb); invBtn.render(sb); if (selectedRecipe != null) craftBtn.render(sb); sb.end(); stage.draw(); }
Example 6
Source File: GigaGalHud.java From ud406 with MIT License | 5 votes |
public void render(SpriteBatch batch, int lives, int ammo, int score) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); // TODO: Draw GigaGal's score and ammo count in the top left of the viewport final String hudString = Constants.HUD_SCORE_LABEL + score + "\n" + Constants.HUD_AMMO_LABEL + ammo; font.draw(batch, hudString, Constants.HUD_MARGIN, viewport.getWorldHeight() - Constants.HUD_MARGIN); // TODO: Draw a tiny GigaGal in the top right for each life left final TextureRegion standingRight = Assets.instance.gigaGalAssets.standingRight; for (int i = 1; i <= lives; i++) { final Vector2 drawPosition = new Vector2( viewport.getWorldWidth() - i * (Constants.HUD_MARGIN / 2 + standingRight.getRegionWidth()), viewport.getWorldHeight() - Constants.HUD_MARGIN - standingRight.getRegionHeight() ); Utils.drawTextureRegion( batch, standingRight, drawPosition ); } batch.end(); }
Example 7
Source File: SlideUpAnimation.java From Radix with MIT License | 5 votes |
@Override public void init() { super.init(); fbo = new FrameBuffer(Pixmap.Format.RGBA4444, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); fboTex = fbo.getColorBufferTexture(); Gdx.gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Gdx.gl.glEnable(GL_BLEND); SpriteBatch batch = new SpriteBatch(); batch.setProjectionMatrix(RadixClient.getInstance().getHudCamera().combined); fbo.bind(); batch.begin(); currentScreen.render(false, batch); batch.end(); FrameBuffer.unbind(); }
Example 8
Source File: Level.java From ud406 with MIT License | 5 votes |
public void render(SpriteBatch batch) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); for (Platform platform : platforms) { platform.render(batch); } exitPortal.render(batch); for (Powerup powerup : powerups) { powerup.render(batch); } for (Enemy enemy : enemies) { enemy.render(batch); } gigaGal.render(batch); for (Bullet bullet : bullets) { bullet.render(batch); } for (Explosion explosion : explosions) { explosion.render(batch); } batch.end(); }
Example 9
Source File: Level.java From ud406 with MIT License | 5 votes |
public void render(SpriteBatch batch) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); for (Platform platform : platforms) { platform.render(batch); } exitPortal.render(batch); for (Powerup powerup : powerups) { powerup.render(batch); } for (Enemy enemy : enemies) { enemy.render(batch); } gigaGal.render(batch); for (Bullet bullet : bullets) { bullet.render(batch); } for (Explosion explosion : explosions) { explosion.render(batch); } batch.end(); }
Example 10
Source File: MatrixSpellerScreen.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
@Override public void draw(){ // Clear screen. Gdx.gl.glClearColor(0,0,0,0); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); SpriteBatch batch = new SpriteBatch(); batch.begin(); batch.disableBlending(); int si=0; for (int x = 0; x < symbols.length; x++) { for (int y = 0; y < symbols[0].length; y++) { if( si< _ss.length ){ if( _ss[si] <= 0 ){ // background bgGrid[x][y].draw(batch); } else if ( _ss[si] == 1 ){ // foreground fgGrid[x][y].draw(batch); } else if ( _ss[si] == 2 ){ // target tgtGrid[x][y].draw(batch); } else if ( _ss[si] == 3 ){ // feedback fbGrid[x][y].draw(batch); } } else { // if not given then set to BG bgGrid[x][y].draw(batch); } si++; } } batch.end(); }
Example 11
Source File: Level.java From ud406 with MIT License | 5 votes |
public void render(SpriteBatch batch) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); for (Platform platform : platforms) { platform.render(batch); } exitPortal.render(batch); for (Powerup powerup : powerups) { powerup.render(batch); } for (Enemy enemy : enemies) { enemy.render(batch); } gigaGal.render(batch); for (Bullet bullet : bullets) { bullet.render(batch); } for (Explosion explosion : explosions) { explosion.render(batch); } batch.end(); }
Example 12
Source File: Level.java From ud406 with MIT License | 4 votes |
public void render(SpriteBatch batch) { batch.begin(); gigaGal.render(batch); batch.end(); }
Example 13
Source File: Sprite3DRenderer.java From bladecoder-adventure-engine with Apache License 2.0 | 4 votes |
@Override public void draw(SpriteBatch batch, float x, float y, float scaleX, float scaleY, float rotation, Color tint) { x = x - getWidth() / 2 * scaleX; if (USE_FBO) { if (tint != null) batch.setColor(tint); batch.draw(tex, x, y, 0, 0, width, height, scaleX, scaleY, 0); if (tint != null) batch.setColor(Color.WHITE); } else { float p0x, p0y, pfx, pfy; updateViewport(); // get screen coords for x and y tmp.set(x, y, 0); tmp.mul(batch.getTransformMatrix()); tmp.prj(batch.getProjectionMatrix()); p0x = VIEWPORT.width * (tmp.x + 1) / 2; p0y = VIEWPORT.height * (tmp.y + 1) / 2; tmp.set(x + width * scaleX, y + height * scaleY, 0); tmp.mul(batch.getTransformMatrix()); tmp.prj(batch.getProjectionMatrix()); pfx = VIEWPORT.width * (tmp.x + 1) / 2; pfy = VIEWPORT.height * (tmp.y + 1) / 2; batch.end(); Gdx.gl20.glViewport((int) (p0x + VIEWPORT.x), (int) (p0y + VIEWPORT.y), (int) (pfx - p0x), (int) (pfy - p0y)); Gdx.gl.glClear(GL20.GL_DEPTH_BUFFER_BIT | (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0)); drawModel(); Gdx.gl20.glViewport((int) VIEWPORT.x, (int) VIEWPORT.y, (int) VIEWPORT.width, (int) VIEWPORT.height); batch.begin(); } }
Example 14
Source File: Level.java From ud406 with MIT License | 4 votes |
public void render(SpriteBatch batch) { batch.begin(); gigaGal.render(batch); batch.end(); }
Example 15
Source File: Level.java From ud406 with MIT License | 4 votes |
public void render(SpriteBatch batch) { batch.begin(); gigaGal.render(batch); batch.end(); }
Example 16
Source File: OnscreenControls.java From ud406 with MIT License | 4 votes |
public void render(SpriteBatch batch) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); if (!Gdx.input.isTouched(jumpPointer)) { gigaGal.jumpButtonPressed = false; jumpPointer = 0; } if (!Gdx.input.isTouched(moveLeftPointer)) { gigaGal.leftButtonPressed = false; moveLeftPointer = 0; } if (!Gdx.input.isTouched(moveRightPointer)) { gigaGal.rightButtonPressed = false; moveRightPointer = 0; } Utils.drawTextureRegion( batch, Assets.instance.onscreenControlsAssets.moveLeft, moveLeftCenter, Constants.BUTTON_CENTER ); Utils.drawTextureRegion( batch, Assets.instance.onscreenControlsAssets.moveRight, moveRightCenter, Constants.BUTTON_CENTER ); Utils.drawTextureRegion( batch, Assets.instance.onscreenControlsAssets.shoot, shootCenter, Constants.BUTTON_CENTER ); Utils.drawTextureRegion( batch, Assets.instance.onscreenControlsAssets.jump, jumpCenter, Constants.BUTTON_CENTER ); batch.end(); }
Example 17
Source File: CreditsScreen.java From bladecoder-adventure-engine with Apache License 2.0 | 4 votes |
@Override public void render(float delta) { final SpriteBatch batch = ui.getBatch(); final int width = (int) viewport.getWorldWidth(); final int height = (int) viewport.getWorldHeight(); Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); if (style.background != null) { style.background.draw(batch, 0, 0, width, height); } scrollY += delta * SPEED * EngineAssetManager.getInstance().getScale(); float y = scrollY; if (stringHead >= credits.size()) ui.setCurrentScreen(Screens.MENU_SCREEN); for (int i = stringHead; i < credits.size(); i++) { String s = credits.get(i); char type = 'c'; // types are 'c' -> credit, 't' -> title, 'i' -> image, 's' -> space, 'm' -> // music if (s.indexOf('#') != -1) { type = s.charAt(0); s = s.substring(2); } switch (type) { case 't': y = processCreditTitle(batch, width, height, y, i, s); break; case 'i': y = processCreditImage(batch, width, height, y, i, s); break; case 's': y = processCreditSpace(height, y, i, s); break; case 'm': processCreditMusic(s); credits.remove(i); i--; break; default: y = processCreditDefault(batch, width, height, y, i, s); break; } if (y < 0) { break; } } batch.end(); }
Example 18
Source File: VictoryOverlay.java From ud406 with MIT License | 3 votes |
public void render(SpriteBatch batch) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); for (Explosion explosion : explosions){ explosion.render(batch); } font.draw(batch, Constants.VICTORY_MESSAGE, viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 2.5f, 0, Align.center, false); batch.end(); }
Example 19
Source File: GameOverOverlay.java From ud406 with MIT License | 3 votes |
public void render(SpriteBatch batch) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); // TODO: Draw a game over message // Feel free to get more creative with this screen. Perhaps you could cover the screen in enemy robots? batch.end(); }
Example 20
Source File: VictoryOverlay.java From ud406 with MIT License | 3 votes |
public void render(SpriteBatch batch) { viewport.apply(); batch.setProjectionMatrix(viewport.getCamera().combined); batch.begin(); for (Explosion explosion : explosions){ explosion.render(batch); } font.draw(batch, Constants.VICTORY_MESSAGE, viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 2.5f, 0, Align.center, false); batch.end(); }