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);

Source Link

Document

Draws a rectangle with the bottom left corner at x,y having the width and height of the region.

Usage

From source file:CB_UI_Base.GL_UI.Controls.Box.java

License:Open Source License

protected void drawBorder(Batch batch) {
    if (borderSprite == null) {
        try {//  w  w w.j a  v a2  s .  com
            GL.that.RunOnGLWithThreadCheck(new IRunOnGL() {

                @Override
                public void run() {

                    int w = (int) getWidth();
                    int h = (int) getHeight();

                    Pixmap borderRegPixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888);
                    borderRegPixmap.setColor(borderColor);

                    int borderAsInt = Math.round(Box.this.borderSize);

                    for (int i = 0; i < borderAsInt + 1; i++) {
                        borderRegPixmap.drawRectangle(i, i, ((int) getWidth()) - (i),
                                ((int) getHeight()) - (i));
                    }

                    borderSprite = new Sprite(new Texture(borderRegPixmap, Pixmap.Format.RGBA8888, false),
                            (int) getWidth(), (int) getHeight());
                }
            });

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    if (borderSprite != null)
        batch.draw(borderSprite, 0, 0);

}

From source file:com.cyphercove.dayinspace.gameplayscene.rendering.Border.java

License:Apache License

/**
 * @param doorOpenTime Use 0 for closed door
 *//*from w  w  w  .  j  av  a2s.c  o  m*/
public void drawBackground(Batch batch, int exitDoorY, float doorOpenTime, int entryDoorY) {
    batch.setColor(Color.WHITE);
    batch.draw(left, -129, 0);
    batch.draw(right, 242, 0);

    if (doorOpenTime != 0)
        batch.draw(exitDoorBehindTile, -SCALE, exitDoorY);

    batch.draw(entryDoor, Board.WIDTH * SCALE, entryDoorY);
}

From source file:com.cyphercove.dayinspace.gameplayscene.rendering.Border.java

License:Apache License

/**
 * @param doorOpenTime Use 0 for closed door
 *//* ww  w  .  j  a  v  a 2  s. c om*/
public void drawForeground(Batch batch, int exitDoorY, float doorOpenTime) {
    batch.setColor(Color.WHITE);
    batch.draw(exitDoor.getKeyFrame(doorOpenTime), -SCALE, exitDoorY + EXIT_DOOR_Y_OFFSET);
    batch.draw(top, -129, 132);
    batch.draw(bottom, -129, -27);
}

From source file:com.gdx.EndlessGame.UIElements.BackgroundAnimation.java

@Override
public void draw(Batch pBatch, float pParentAlpha) {
    try {//w ww. jav  a  2s  . co  m
        _duration += Gdx.graphics.getDeltaTime();
        TextureRegion frame = _background.getKeyFrame(_duration, true);
        pBatch.draw(frame, getX(), getY());
    } catch (Exception e) {
        System.out.println(e.toString());
    }
}

From source file:com.gdx.EndlessGame.UIElements.ShootingPad.java

@Override
public void draw(Batch pBatch, float pParentAlpha) {
    try {/*from www.j  ava 2s  .  c o  m*/
        pBatch.draw(_button, getX(), getY());
    } catch (Exception e) {
        System.out.println(e.toString());
    }
}

From source file:com.jlabarca.texture.ButtonSprite.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    batch.draw(textureRegion, this.getX(), this.getY());
}

From source file:com.jlabarca.texture.FrameSprite.java

License:Apache License

/**
 * Draw sprite./*  w ww  . j a  v a 2  s.  c  o m*/
 * 
 */
@Override
public void draw(Batch batch, float parentAlpha) {
    stateTime += Gdx.graphics.getDeltaTime();
    currentFrame = animation.getKeyFrame(stateTime, this.looping);

    batch.draw(currentFrame, this.getX(), this.getY());
}

From source file:com.jupiter.europa.scene2d.TextureRegionActor.java

@Override
public void draw(Batch batch, float parentAlpha) {
    System.out.println("Drawing");
    batch.draw(this.region, this.getX(), this.getY());
}

From source file:com.kotcrab.vis.editor.module.scene.entitymanipulator.tool.PolygonTool.java

License:Apache License

@Override
public void render(Batch batch) {
    lineOverStartVertex = null;//from   ww  w. j  av  a 2s.c  om

    if (component != null) {
        batch.setProjectionMatrix(stage.getCamera().combined);

        camera.unproject(tmpVector.set(Gdx.input.getX(), Gdx.input.getY(), 0));

        float worldMouseX = tmpVector.x;
        float worldMouseY = tmpVector.y;

        drawnFacesLines.clear();
        if ((dynamicUpdateCheck.isChecked() == false && Gdx.input.isButtonPressed(Buttons.LEFT)) == false) {
            batch.setColor(Color.GRAY);
            if (component.faces != null) {
                for (int i = 0; i < component.faces.length; i++) {
                    Vector2[] faces = component.faces[i];

                    for (int j = 1; j < faces.length; j++) {
                        drawFaceLine(batch, faces[j], faces[j - 1]);
                    }

                    drawFaceLine(batch, faces[0], faces[faces.length - 1]);
                }
            }
        }

        Array<Vector2> vertices = component.vertices;
        batch.setColor(mainColor);
        for (int i = 1; i < vertices.size; i++) {
            drawPolygonBorderLine(batch, vertices.get(i), vertices.get(i - 1), worldMouseX, worldMouseY);
        }

        if (vertices.size > 1) {
            drawPolygonBorderLine(batch, vertices.get(0), vertices.get(vertices.size - 1), worldMouseX,
                    worldMouseY);
        }

        batch.setColor(Color.WHITE);
        for (Vector2 vertex : vertices) {
            tmpVector.set(vertex.x, vertex.y, 0);
            camera.project(tmpVector);

            TextureRegion region = polygon;

            if (vertex == selectedVertex)
                region = polygonDown;
            else if (vertex == overVertex)
                region = polygonOver;

            batch.draw(region, tmpVector.x - POLYGON_RECT_SIZE / 2, tmpVector.y - POLYGON_RECT_SIZE / 2);
        }
    }
}

From source file:com.kotcrab.vis.editor.scene.MusicObject.java

License:Apache License

@Override
public void render(Batch batch) {
    batch.draw(icon, x, y);
}