List of usage examples for com.badlogic.gdx.graphics.g2d SpriteBatch isDrawing
public boolean isDrawing()
From source file:com.gamejolt.mikykr5.ceidecpong.effects.ScrollingBackground.java
License:Open Source License
/** * Render this effect.//ww w . j a v a 2s . c o m * * @param batch The {@link SpriteBatch} to use for the rendering. * @throws IllegalStateException If the {@link SpriteBatch} did not call {@link SpriteBatch#begin()} befor this method was called. */ public void render(SpriteBatch batch) throws IllegalStateException { if (!batch.isDrawing()) throw new IllegalStateException("Must be called between SpriteBatch.begin() and SpriteBatch.end()"); // If the shader was loaded then set it as the current shader. if (shader != null) { batch.setShader(shader); shader.setUniformf(u_scaling, scaling); shader.setUniformf(u_displacement, displacement); } // Render. background.draw(batch); // If the shader was loaded then disable it. if (shader != null) batch.setShader(null); // Update the displacement a little bit. // GOTCHA: This will look slower or faster depending on the speed of the computer. displacement = displacement < 0.0f ? 1.0f : displacement - 0.0005f; }
From source file:com.mygdx.game.debugdrawers.NavMeshDebugDrawer.java
License:Apache License
private void drawNavMeshIndices(SpriteBatch spriteBatch, Camera camera, BitmapFont font) { // TODO: Get rid of all the transform matrix setting if (spriteBatch.isDrawing()) { spriteBatch.end();// w ww . ja v a 2s . co m } 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(); }