List of usage examples for com.badlogic.gdx.graphics.g2d SpriteBatch flush
@Override
public void flush()
From source file:com.anstrat.gui.SnapScrollPane.java
License:Apache License
@Override public void draw(SpriteBatch batch, float parentAlpha) { if (widget == null) return;//from w w w . j av a 2 s .com validate(); // Setup transform for this group. applyTransform(batch, computeTransform()); if (scrollX) hKnobBounds.x = hScrollBounds.x + (int) ((hScrollBounds.width - hKnobBounds.width) * getScrollPercentX()); if (scrollY) vKnobBounds.y = vScrollBounds.y + (int) ((vScrollBounds.height - vKnobBounds.height) * (1 - getScrollPercentY())); // Calculate the widget's position depending on the scroll state and available widget area. float y = widgetAreaBounds.y; if (!scrollY) y -= (int) maxY; else y -= (int) (maxY - visualAmountY); if (scrollbarsOnTop && scrollX) { float scrollbarHeight = 0; if (style.hScrollKnob != null) scrollbarHeight = style.hScrollKnob.getMinHeight(); if (style.hScroll != null) scrollbarHeight = Math.max(scrollbarHeight, style.hScroll.getMinHeight()); y += scrollbarHeight; } float x = widgetAreaBounds.x; if (scrollX) x -= (int) visualAmountX; widget.setPosition(x, y); if (widget instanceof Cullable) { widgetCullingArea.x = -widget.getX() + widgetAreaBounds.x; widgetCullingArea.y = -widget.getY() + widgetAreaBounds.y; widgetCullingArea.width = widgetAreaBounds.width; widgetCullingArea.height = widgetAreaBounds.height; ((Cullable) widget).setCullingArea(widgetCullingArea); } // Caculate the scissor bounds based on the batch transform, the available widget area and the camera transform. We need to // project those to screen coordinates for OpenGL ES to consume. ScissorStack.calculateScissors(getStage().getCamera(), batch.getTransformMatrix(), widgetAreaBounds, scissorBounds); // Draw the background ninepatch. Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); if (style.background != null) style.background.draw(batch, 0, 0, getWidth(), getHeight()); batch.flush(); // Enable scissors for widget area and draw the widget. if (ScissorStack.pushScissors(scissorBounds)) { drawChildren(batch, parentAlpha); ScissorStack.popScissors(); } // Render scrollbars and knobs on top. batch.setColor(color.r, color.g, color.b, color.a * parentAlpha * Interpolation.fade.apply(fadeAlpha / fadeAlphaSeconds)); if (scrollX && scrollY) { if (style.corner != null) { style.corner.draw(batch, hScrollBounds.x + hScrollBounds.width, hScrollBounds.y, vScrollBounds.width, vScrollBounds.y); } } if (scrollX) { if (style.hScroll != null) style.hScroll.draw(batch, hScrollBounds.x, hScrollBounds.y, hScrollBounds.width, hScrollBounds.height); if (style.hScrollKnob != null) style.hScrollKnob.draw(batch, hKnobBounds.x, hKnobBounds.y, hKnobBounds.width, hKnobBounds.height); } if (scrollY) { if (style.vScroll != null) style.vScroll.draw(batch, vScrollBounds.x, vScrollBounds.y, vScrollBounds.width, vScrollBounds.height); if (style.vScrollKnob != null) style.vScrollKnob.draw(batch, vKnobBounds.x, vKnobBounds.y, vKnobBounds.width, vKnobBounds.height); } resetTransform(batch); }
From source file:es.eucm.ead.engine.gameobjects.sceneelements.transitions.MaskTransitionGO.java
License:Open Source License
@Override public void drawChildren(SpriteBatch batch, float parentAlpha) { previousScene.setVisible(true);// ww w . ja va 2 s .c o m nextScene.setVisible(false); super.drawChildren(batch, parentAlpha); batch.end(); nextSceneBuffer.begin(); batch.begin(); previousScene.setVisible(false); nextScene.setVisible(true); super.drawChildren(batch, parentAlpha); nextSceneBuffer.end(); batch.flush(); batch.setShader(maskShader); maskShader.setAttributef("a_offset", offset.x, offset.y, offset.z, 0); texture.bind(1); Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0); Gdx.gl.glBindTexture(GL10.GL_TEXTURE_2D, 0); batch.draw(nextSceneBuffer.getColorBufferTexture(), 0, 0); batch.setShader(null); }
From source file:hku.fyp14017.blencode.stage.Passepartout.java
License:Open Source License
@Override public void draw(SpriteBatch batch, float parentAlpha) { if (Float.compare(passepartoutWidth, 0f) != 0) { batch.draw(texture, -virtualScreenWidth / 2f, -virtualScreenHeight / 2f, -passepartoutWidth, virtualScreenHeight);/*from w ww . j av a 2 s .c o m*/ batch.draw(texture, virtualScreenWidth / 2f, virtualScreenHeight / 2f, passepartoutWidth, -virtualScreenHeight); } if (Float.compare(passepartoutHeight, 0f) != 0) { batch.draw(texture, -virtualScreenWidth / 2f, -virtualScreenHeight / 2f, virtualScreenWidth, -passepartoutHeight); batch.draw(texture, virtualScreenWidth / 2f, virtualScreenHeight / 2f, -virtualScreenWidth, passepartoutHeight); } batch.flush(); }
From source file:pl.kotcrab.jdialogue.editor.components.types.TextComponent.java
License:Open Source License
@Override public void render(SpriteBatch batch) { super.render(batch); ScissorStack.calculateScissors(camera, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), batch.getTransformMatrix(), getBounds(), scissors); ScissorStack.pushScissors(scissors); label.setPosition(x, y - label.getPrefHeight() / 2 - 30); label.draw(batch, 1);/*w ww . jav a2 s.c om*/ batch.flush(); ScissorStack.popScissors(); }