List of usage examples for com.badlogic.gdx.graphics.g2d SpriteBatch setColor
@Override
public void setColor(float r, float g, float b, float a)
From source file:at.tugraz.ist.catroid.plugin.Drone.other.DroneVideoCostume.java
License:Open Source License
@Override public void draw(SpriteBatch batch, float parentAlpha) { if (firstStart) { initializeTexture();/*w w w . j a v a 2 s . c o m*/ } else { DroneHandler.getInstance().getDrone() .renderVideoFrame(this.region.getTexture().getTextureObjectHandle()); int newCameraOrientation = DroneHandler.getInstance().getDrone().getCameraOrientation(); if (oldCameraOrientation != newCameraOrientation) { oldCameraOrientation = newCameraOrientation; if (newCameraOrientation == 1) { this.region.setRegion(0, 0, 176, 144); } else { this.region.setRegion(0, 0, 320, 240); } } if (region.getTexture() != null) { batch.setColor(color.r, color.g, color.b, color.a * this.alphaValue); if (scaleX == 1 && scaleY == 1 && rotation == 0) { batch.draw(region, x, y, width, height); } else { batch.draw(region, x, y, originX, originY, width, height, scaleX, scaleY, rotation); } } } }
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 a v a 2 s.c o m 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:com.binarytenshi.nopassing.core.environment.StreetHandler.java
public static void draw(SpriteBatch batch) { for (int x = 0; x < MapHandler.getMapSize().x; x++) { for (int y = 0; y < MapHandler.getMapSize().y; y++) { Sprite sprite = getSprite(x, y); if (highlight != null && highlight.x == x && highlight.y == y) { batch.setColor(1f, 1f, 1f, .5f); batch.draw(sprite, x * TextureLib.tileSide, y * TextureLib.tileSide, TextureLib.tileSide / 2, TextureLib.tileSide / 2, TextureLib.tileSide, TextureLib.tileSide, 1f, 1f, 90 - sprite.getRotation(), true); batch.setColor(1f, 1f, 1f, 1f); }/*from ww w. j ava 2 s . c o m*/ if (streetMap[x][y]) { batch.draw(sprite, x * TextureLib.tileSide, y * TextureLib.tileSide, TextureLib.tileSide / 2, TextureLib.tileSide / 2, TextureLib.tileSide, TextureLib.tileSide, 1f, 1f, 90 - sprite.getRotation(), true); } } } }
From source file:com.bnotions.racing.actor.ButtonActor.java
License:Apache License
@Override public void draw(SpriteBatch batch, float parentAlpha) { TextureRegion region = pressed ? pressedRegion : unpressedRegion; batch.setColor(getColor().r, getColor().g, getColor().b, getColor().a * parentAlpha); if (region.getTexture() != null) { if (getScaleX() == 0 && getScaleY() == 0 && getRotation() == 0) batch.draw(region, getX(), getY(), getWidth(), getHeight()); else//from w w w . ja v a 2s .c o m batch.draw(region, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation()); } }
From source file:com.cyphercove.doublehelix.FilmGrain.java
License:Apache License
@Override public void applyCustomShaderParameters(SpriteBatch spriteBatch, boolean flipped) { spriteBatch.setColor(Settings.filmGrain ? FILM_GRAIN_BRIGHTNESS : 0, Settings.scanLines ? SCANLINE_BRIGHTNESS : 0, Settings.vignette ? VIGNETTE_BRIGHTNESS : 0, 1); if (flipped) { swapVector2(mFilmGrainInverse);//from www. j ava 2 s . c om } filmGrainShaderProgram.setUniformf(u_grainInverse, mFilmGrainInverse); filmGrainShaderProgram.setUniformf(u_scanLineInverse, mScanLineInverse); filmGrainShaderProgram.setUniformf(u_flipped, flipped ? 1f : 0f); filmGrainShaderProgram.setUniformf(u_grainOffset, mRandom.nextFloat() * mFilmGrainInverse.x, mRandom.nextFloat() * mFilmGrainInverse.y); filmGrainShaderProgram.setUniformf(u_flicker, lerp(0.96f, 1f, mRandom.nextFloat())); noiseTexture.bind(1); scanlineTexture.bind(2); borderTexture.bind(3); Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0); filmGrainShaderProgram.setUniformi(u_noiseTexture, 1); filmGrainShaderProgram.setUniformi(u_scanLineTexture, 2); filmGrainShaderProgram.setUniformi(u_borderTexture, 3); if (flipped) { swapVector2(mFilmGrainInverse); } }
From source file:com.dinhanh.myUtils.ScreenTransitionFade.java
License:Apache License
@Override public void render(SpriteBatch batch, Texture currScreen, Texture nextScreen, float alpha) { float w = currScreen.getWidth(); float h = currScreen.getHeight(); alpha = Interpolation.fade.apply(alpha); Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); batch.begin();//from w ww . j a va2 s . co m batch.setColor(1, 1, 1, 1); batch.draw(currScreen, 0, 0, 0, 0, w, h, 1, 1, 0, 0, 0, currScreen.getWidth(), currScreen.getHeight(), false, true); batch.setColor(1, 1, 1, alpha); batch.draw(nextScreen, 0, 0, 0, 0, w, h, 1, 1, 0, 0, 0, nextScreen.getWidth(), nextScreen.getHeight(), false, true); batch.end(); }
From source file:com.havidarou.MeduNetjer.scene2d.AbstractActor.java
License:Apache License
public void draw(SpriteBatch batch, float parentAlpha) { super.draw(batch, parentAlpha); // For fade out/in effect batch.setColor(this.getColor().r, this.getColor().g, this.getColor().b, parentAlpha * this.getColor().a); // DRAW TEXTURE REGION (Draw only if set active and not null) // ################################################################## if (isTextureRegionActive && textureRegion != null) { // Draw it due to actors' settings batch.draw(textureRegion, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation()); }/*from w ww . j a v a 2 s . c o m*/ // DRAW ANIMATION (Draw only if set active and not null) // ################################################################## if (isAnimationActive && animation != null) { // Get frame by frame and animate TextureRegion keyFrame = animation.getKeyFrame(stateTime, isAnimationLooping); // Draw it due to actors' settings batch.draw(keyFrame, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation()); if (animation.isAnimationFinished(stateTime)) { if (killAllAnimations) { isAnimationActive = false; } } } // DRAW ANIMATION MOMENTARY (Draw only if set active and not null) // ################################################################## if (isAnimationMomentaryActive && animationMomentary != null) { if (animationMomentary.isAnimationFinished(stateTime)) { if (!killAllAnimations) { isAnimationActive = true; isAnimationMomentaryActive = false; isAnimationMomentaryFinished = true; startTime = 0; } else { isAnimationActive = false; isAnimationMomentaryActive = false; isAnimationMomentaryFinished = true; startTime = 0; } } if (isAnimationMomentaryActive) { // Get frame by frame and animate TextureRegion keyFrame = animationMomentary.getKeyFrame(stateTime, false); // Draw it due to actors' settings batch.draw(keyFrame, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation()); } } // PARTICLE // ################################################################# if (isParticleEffectActive) { particleEffect.draw(batch, Gdx.graphics.getDeltaTime()); particleEffect.setPosition(getX() + particlePosX, getY() + particlePosY); } }
From source file:com.havidarou.MeduNetjer.scene2d.AbstractActorLight.java
License:Apache License
public void draw(SpriteBatch batch, float parentAlpha) { super.draw(batch, parentAlpha); // For fade out/in effect batch.setColor(this.getColor().r, this.getColor().g, this.getColor().b, parentAlpha * this.getColor().a); // DRAW TEXTURE REGION (Draw only if set active and not null) // ################################################################## if (isTextureRegionActive && textureRegion != null) { // Draw it due to actors' settings batch.draw(textureRegion, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation()); }/*from www .j a v a 2s . c o m*/ }
From source file:com.iLoong.launcher.UI3DEngine.TextField3D.java
License:Open Source License
@Override public void draw(SpriteBatch batch, float parentAlpha) { super.draw(batch, parentAlpha); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); boolean focused = stage != null && stage.getKeyboardFocus() == this; if (displayTextTexture != null) { batch.draw(displayTextTexture, x + (mediate ? displayOffsetX : 0), y); }/*from w w w .j a v a 2s . c o m*/ if (focused && editable) { blink(); if (cursorOn && cursorPatch != null) { cursorPatch.draw(batch, x + (mediate ? displayOffsetX : 0) + visibleTextEnd, y + (this.height - cursorHeight) / 2, cursorPatch.getTotalWidth(), cursorHeight); } Gdx.graphics.requestRendering(); } }
From source file:com.longarmx.color.ComponentClickableButton.java
License:Apache License
/** * Renders this component./*from w ww .j a va 2s . c o m*/ */ public void render(SpriteBatch batch) { // If mouse button is hovering over this component. if (selected) { // Set the color to the highlight color. batch.setColor(r, g, b, 1); } else { // Else light up the button batch.setColor(1, 1, 1, 1); } super.render(batch); // Render the text over the button. manager.draw(text, x + width / 2 - (int) manager.getTextWidth(text, scale) / 2, y + height / 2 - (int) manager.getTextHeight(scale) / 2, scale, batch); }