Example usage for com.badlogic.gdx.graphics.g2d Batch draw

List of usage examples for com.badlogic.gdx.graphics.g2d Batch draw

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d Batch draw.

Prototype

public void draw(TextureRegion region, float x, float y, float originX, float originY, float width,
        float height, float scaleX, float scaleY, float rotation);

Source Link

Document

Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.

Usage

From source file:broken.shotgun.throwthemoon.actors.Boss.java

License:Open Source License

@Override
public void draw(Batch batch, float parentAlpha) {
    super.draw(batch, parentAlpha);
    batch.setColor(getColor());/*  www .jav a  2s .  c o  m*/
    batch.draw(currentFrame, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(),
            flipX ? getScaleX() : -getScaleX(), getScaleY(), getRotation());
    batch.setColor(Color.WHITE);
}

From source file:broken.shotgun.throwthemoon.actors.Enemy.java

License:Open Source License

@Override
public void draw(Batch batch, float parentAlpha) {
    super.draw(batch, parentAlpha);
    batch.setColor(getColor());/*from   www .j av  a2  s  .  com*/
    batch.draw(currentFrame, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(),
            getScaleY(), getRotation());
    batch.setColor(Color.WHITE);
}

From source file:broken.shotgun.throwthemoon.actors.Moon.java

License:Open Source License

@Override
public void draw(Batch batch, float parentAlpha) {
    super.draw(batch, parentAlpha);
    batch.draw(currentFrame, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(),
            getScaleY(), getRotation());
}

From source file:broken.shotgun.throwthemoon.actors.Player.java

License:Open Source License

@Override
public void draw(Batch batch, float parentAlpha) {
    super.draw(batch, parentAlpha);
    batch.setColor(getColor());//ww  w  . j a va  2 s . c o m
    batch.draw(currentFrame, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(),
            flipX ? -getScaleX() : getScaleX(), getScaleY(), getRotation());
    batch.setColor(Color.WHITE);
}

From source file:CB_UI_Base.GL_UI.Controls.Animation.RotateAnimation.java

License:Open Source License

@Override
protected void render(Batch batch) {

    if (mDrawable == null)
        return;//w w w . java2  s .com

    // ####################################################################
    // calc Rotation
    // ####################################################################

    animateRotateValue = (1
            + ((int) (GL.that.getStateTime() * 1000) % this.mDuration) / (this.mDuration / 360));

    // ####################################################################
    // Draw
    // ####################################################################

    float drawwidth = getWidth();
    float drawHeight = getHeight();
    float drawX = 0;
    float drawY = 0;

    if (mSpriteWidth > 0 && mSpriteHeight > 0) {
        float proportionWidth = getWidth() / mSpriteWidth;
        float proportionHeight = getHeight() / mSpriteHeight;

        float proportion = Math.min(proportionWidth, proportionHeight);

        drawwidth = mSpriteWidth * proportion;
        drawHeight = mSpriteHeight * proportion;
        drawX = (getWidth() - drawwidth) / 2;
        drawY = (getHeight() - drawHeight) / 2;
    }

    batch.draw(mDrawable, drawX, drawY, mOriginX, mOriginY, drawwidth, drawHeight, mScale, mScale,
            animateRotateValue);

    GL.that.renderOnce();

}

From source file:CB_UI_Base.graphics.Images.BitmapDrawable.java

License:Open Source License

public void draw(Batch batch, float x, float y, float originX, float originY, float width, float height,
        float scaleX, float scaleY, float rotation) {
    if (Atlas == null)
        return;/*from  w w  w.java  2  s .co  m*/
    if (sprite == null)
        createSprite();
    if (sprite != null)
        batch.draw(sprite, x, y, originX, originY, width, height, scaleX, scaleY, rotation);
}

From source file:coder5560.gdxai.SteeringActor.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    Color color = getColor();//from ww  w .  j a va2  s .c o  m
    batch.setColor(color.r, color.g, color.b, parentAlpha);
    batch.draw(region, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(),
            getScaleY(), getRotation());
}

From source file:com.agateau.pixelwheels.bonus.Missile.java

License:Open Source License

private void drawReactorFire(Batch batch) {
    TextureRegion region = mAssets.turboFlame.getKeyFrame(mTime, true);
    Vector2 center = mBody.getPosition();
    float angle = mBody.getAngle();
    float w = Constants.UNIT_FOR_PIXEL * region.getRegionWidth();
    float h = Constants.UNIT_FOR_PIXEL * region.getRegionHeight();
    float refH = Constants.UNIT_FOR_PIXEL * -WIDTH / 2;
    float x = center.x + refH * MathUtils.cos(angle);
    float y = center.y + refH * MathUtils.sin(angle);
    batch.draw(region, x - w / 2, y - h, // pos
            w / 2, h, // origin
            w, h, // size
            1, 1, // scale
            angle * MathUtils.radDeg - 90);
}

From source file:com.agateau.pixelwheels.racer.VehicleRenderer.java

License:Open Source License

private void drawTurbo(Batch batch) {
    TextureRegion region = mAssets.turboFlame.getKeyFrame(mVehicle.getTurboTime(), true);
    Body body = mVehicle.getBody();/*from  w ww  .  j  a v a 2 s  .  c om*/
    Vector2 center = body.getPosition();
    float angle = body.getAngle() * MathUtils.radiansToDegrees;
    float w = Constants.UNIT_FOR_PIXEL * region.getRegionWidth();
    float h = Constants.UNIT_FOR_PIXEL * region.getRegionHeight();
    float refH = -mVehicle.getWidth() / 2;
    float x = center.x + refH * MathUtils.cosDeg(angle);
    float y = center.y + refH * MathUtils.sinDeg(angle);
    batch.draw(region, x - w / 2, y - h, // pos
            w / 2, h, // origin
            w, h, // size
            1, 1, // scale
            angle - 90);
}

From source file:com.agateau.ui.TextureRegionItemRendererAdapter.java

License:Apache License

@Override
public void render(Batch batch, float x, float y, float width, float height, T item) {
    TextureRegion region = getItemRegion(item);
    updateRenderInfo(width, height, region);
    float rWidth = region.getRegionWidth();
    float rHeight = region.getRegionHeight();
    batch.draw(region, x + (width - rWidth) / 2, y + (height - rHeight) / 2, // pos
            rWidth / 2, rHeight / 2, // origin
            rWidth, rHeight, // width
            mScale, mScale, // scale
            mAngle // rotation
    );/*from w  w  w  .  j  a  va  2s  . co m*/
}