List of usage examples for com.badlogic.gdx.graphics.g2d SpriteBatch draw
@Override
public void draw(TextureRegion region, float x, float y, float originX, float originY, float width,
float height, float scaleX, float scaleY, float rotation)
From source file:at.therefactory.jewelthief.misc.Utils.java
License:Open Source License
public static void oscilliate(SpriteBatch batch, Sprite sprite, float x, float y, float width, float height, float elapsedTime) { batch.draw(sprite, x, y, 0, 0, width, height, Utils.oscilliate(elapsedTime, scaleMin, scaleMax, period), Utils.oscilliate(elapsedTime, scaleMin, scaleMax, -period), Utils.oscilliate(elapsedTime, -rotate, rotate, period)); }
From source file:be.ac.ucl.lfsab1509.bouboule.game.gameManager.GraphicManager.java
License:Open Source License
/** * Draw the background with scalling if needed * @param sp : SpriteBatch to draw to/* w ww . j a v a 2 s . com*/ * * draw(SpriteBatch batch) */ public void drawBackground(final SpriteBatch batch) { // If the background is upscaled, we must use a TextureRegion if (GlobalSettings.SCALE != 1f) { batch.draw(backgroundRegion, GlobalSettings.SHIFT_BG_WIDTH, GlobalSettings.SHIFT_BG_HEIGHT, 0f, 0f, backgroundRegion.getRegionWidth(), backgroundRegion.getRegionHeight(), GlobalSettings.SCALE, GlobalSettings.SCALE, 0f); } else { batch.draw(background, GlobalSettings.SHIFT_BG_WIDTH, 0f); } }
From source file:ca.viaware.game.entity.Entity.java
License:Open Source License
@Override public void render(SpriteBatch batch) { batch.draw(getTexture(), getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation()); }
From source file:com.badlogicgames.superjumper.Spring.java
License:Apache License
public void draw(SpriteBatch batch) { switch (this.rendertype) { case 0:// ww w. j a va2 s . c o m //batch.draw(Assets.meteoragrigiaRegion, platform.position.x - 0.75f, platform.position.y - 0.75f, Platform.PLATFORM_WIDTH, Platform.PLATFORM_HEIGHT); batch.draw(texture5, this.position.x - 0.75f, this.position.y, UI.SPRING_WIDTH / 2, UI.SPRING_HEIGHT / 2, UI.SPRING_WIDTH, UI.SPRING_HEIGHT, 1, 1, this.rotation); break; case 1: //batch.draw(Assets.meteorabluRegion, platform.position.x - 0.75f, platform.position.y - 0.75f, Platform.PLATFORM_WIDTH, Platform.PLATFORM_HEIGHT); batch.draw(texture5, this.position.x - 0.75f, this.position.y, UI.SPRING_WIDTH / 2, UI.SPRING_HEIGHT / 2, UI.SPRING_WIDTH, UI.SPRING_HEIGHT, 1, 1, this.rotation * 0.8f); break; case 2: //batch.draw(Assets.meteorarosaRegion, platform.position.x - 0.75f, platform.position.y - 0.75f, Platform.PLATFORM_WIDTH, Platform.PLATFORM_HEIGHT); batch.draw(texture5, this.position.x - 0.75f, this.position.y, UI.SPRING_WIDTH / 2, UI.SPRING_HEIGHT / 2, UI.SPRING_WIDTH, UI.SPRING_HEIGHT, 1, 1, this.rotation * 1.5f); break; case 3: //batch.draw(Assets.meteoragiallaRegion, platform.position.x - 0.75f, platform.position.y - 0.75f, Platform.PLATFORM_WIDTH, Platform.PLATFORM_HEIGHT); batch.draw(texture5, this.position.x - 0.75f, this.position.y, UI.SPRING_WIDTH / 2, UI.SPRING_HEIGHT / 2, UI.SPRING_WIDTH, UI.SPRING_HEIGHT, 1, 1, this.rotation / 2); break; default: //Gdx.app.debug("RENDERPLATFORMS", "platform.rendertype = " + this.rendertype); } }
From source file:com.badlogicgames.superjumper.Spring.java
License:Apache License
public void draw(SpriteBatch batch, TextureRegion variable, float width, float height) { batch.draw(variable, position.x, position.y, width / 2, height / 2, width, height, 1, 1, stateTime * 15); }
From source file:com.bladecoder.engine.model.AtlasRenderer.java
License:Apache License
@Override public void draw(SpriteBatch batch, float x, float y, float scale) { if (tex == null) { x = x - getWidth() / 2 * scale;/*from ww w. ja v a2 s .com*/ RectangleRenderer.draw(batch, x, y, getWidth() * scale, getHeight() * scale, Color.RED); return; } x = x + tex.offsetX - tex.originalWidth / 2; y = y + tex.offsetY - tex.originalHeight * (1 - scale) / 2; if (!flipX) { batch.draw(tex, x, y, tex.originalWidth / 2 - tex.offsetX, tex.originalHeight / 2 - tex.offsetY, tex.packedWidth, tex.packedHeight, scale, scale, 0); } else { batch.draw(tex, x, y, tex.originalWidth / 2 - tex.offsetX, tex.originalHeight / 2 - tex.offsetY, tex.packedWidth, tex.packedHeight, -scale, scale, 0); } }
From source file:com.bladecoder.engine.model.Sprite3DRenderer.java
License:Apache License
@Override public void draw(SpriteBatch batch, float x, float y, float scale) { x = x - getWidth() / 2 * scale;/*from w w w. j a va2s . co m*/ if (USE_FBO) { batch.draw(tex, x, y, 0, 0, width, height, scale, scale, 0); } else { float p0x, p0y, pfx, pfy; Vector3 tmp = new Vector3(); // TODO Make static for performance? 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 * scale, y + height * scale, 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(); } }
From source file:com.bladecoder.engine.ui.defaults.ScenePointer.java
License:Apache License
public void draw(SpriteBatch batch, Viewport v) { getInputUnproject(v, mousepos);//from w w w.j a v a2 s . c om boolean multiTouch = Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen); // DRAW TARGET DESCRIPTION if (desc != null && (!multiTouch || Gdx.input.isTouched())) { float margin = DPIUtils.UI_SPACE; float textX = mousepos.x - layout.width / 2; float textY = mousepos.y + layout.height + DPIUtils.UI_SPACE + DPIUtils.getTouchMinSize(); if (textX < 0) textX = 0; RectangleRenderer.draw(batch, textX - margin, textY - layout.height - margin, layout.width + margin * 2, layout.height + margin * 2, Color.BLACK); font.draw(batch, layout, textX, textY); } if (draggingRenderer == null) { if (!multiTouch || currentIcon == leaveIcon) { batch.draw(currentIcon, mousepos.x - currentIcon.getRegionWidth() / 2, mousepos.y - currentIcon.getRegionHeight() / 2, currentIcon.getRegionWidth() / 2, currentIcon.getRegionHeight() / 2, currentIcon.getRegionWidth(), currentIcon.getRegionHeight(), pointerScale, pointerScale, currentIcon == leaveIcon ? leaveRotation : 0); } } else { float h = (draggingRenderer.getHeight() > draggingRenderer.getWidth() ? draggingRenderer.getHeight() : draggingRenderer.getWidth()); float size = DPIUtils.getTouchMinSize() / h * 1.8f; if (currentIcon != hotspotIcon) { batch.setColor(DRAG_NOT_HOTSPOT_COLOR); } draggingRenderer.draw(batch, mousepos.x, mousepos.y - draggingRenderer.getHeight() * size / 2, size); if (currentIcon != hotspotIcon) { batch.setColor(Color.WHITE); } } }
From source file:com.github.skittishSloth.openSkies.battles.ships.PlayerShip.java
public void render(final SpriteBatch batch, final float delta) { final TextureRegion curFrame = getCurrentFrame(delta); final int width = curFrame.getRegionWidth(); final int height = curFrame.getRegionHeight(); final float originX = width / 2; final float originY = height / 2; final Vector2 origin = new Vector2(originX, originY); origin.add(position);//from w w w . ja v a2 s .co m final Vector2 lo = laserOffset.cpy(); lo.setAngle(rotation + 90); lo.add(origin); laserPosition.set(lo); batch.draw(curFrame, position.x, position.y, originX, originY, width, height, 1.0f, 1.0f, getRotation()); }
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 . ja v a2s .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); } }