Example usage for com.badlogic.gdx.graphics.g2d SpriteBatch dispose

List of usage examples for com.badlogic.gdx.graphics.g2d SpriteBatch dispose

Introduction

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

Prototype

@Override
    public void dispose() 

Source Link

Usage

From source file:com.bladecoder.engineeditor.ui.SceneList.java

License:Apache License

private TextureRegion createBgIcon(String atlas, String region) {
    TextureAtlas a = new TextureAtlas(Gdx.files
            .absolute(Ctx.project.getProjectPath() + "/" + Project.ATLASES_PATH + "/1/" + atlas + ".atlas"));
    AtlasRegion r = a.findRegion(region);

    if (r == null) {
        a.dispose();// w  w w  .  j  a v a2s . c  o  m
        return null;
    }

    FrameBuffer fbo = new FrameBuffer(Format.RGBA8888, 200,
            (int) (r.getRegionHeight() * 200f / r.getRegionWidth()), false);

    SpriteBatch fboBatch = new SpriteBatch();
    fboBatch.setColor(Color.WHITE);
    OrthographicCamera camera = new OrthographicCamera();
    camera.setToOrtho(false, fbo.getWidth(), fbo.getHeight());
    fboBatch.setProjectionMatrix(camera.combined);

    Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
    fbo.begin();
    fboBatch.begin();
    fboBatch.draw(r, 0, 0, fbo.getWidth(), fbo.getHeight());
    fboBatch.end();

    TextureRegion tex = ScreenUtils.getFrameBufferTexture(0, 0, fbo.getWidth(), fbo.getHeight());
    // tex.flip(false, true);

    fbo.end();
    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);

    fbo.dispose();
    a.dispose();
    fboBatch.dispose();

    return tex;
}

From source file:com.bossletsplays.rr.gfx.Texture2D.java

License:Apache License

public static void dispose(SpriteBatch batch) {
    batch.dispose();
}

From source file:com.bossletsplays.rr.gfx.Texture2D.java

License:Apache License

public static void dispose(SpriteBatch batch, Sprite sprite) {
    batch.dispose();
    sprite.getTexture().dispose();/*from   w w w  .  ja  v  a 2s . c om*/
    LogHelper.track("Disposed texture <"
            + ((FileTextureData) sprite.getTexture().getTextureData()).getFileHandle().name() + ">");
}

From source file:com.redthirddivision.astilade.render.Texture2D.java

License:Apache License

public static void dispose(SpriteBatch batch, Sprite sprite) {
    batch.dispose();
    sprite.getTexture().dispose();/*from  w  w  w .  j  a  v a2 s. com*/
    LogHelper.info("Disposed texture <"
            + ((FileTextureData) sprite.getTexture().getTextureData()).getFileHandle().name() + ">");
}

From source file:EntityManager.RenderSystem.java

public static void render() {
    if (bullets.size() > 100) {
        for (int i = 50; i > 0; i--) {
            world.destroyBody(bm.get(bullets.get(i)).body);
            EntityManager.destroy(bullets.get(i));
        }/*from   w  ww  .j a  va 2s.  c  o  m*/
    }

    SpriteBatch batch = new SpriteBatch();
    Sprite player;// = TextureHolder.initializePlayer(bm.get(players.first()).body);

    Texture tex = new Texture("player.gif");
    player = new Sprite(tex);
    //            player.scale(1f);

    player.scale(SCALE * -.3f);
    player.setCenter(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
    player.rotate((float) Math.toDegrees(bm.get(players.first()).body.getAngle()));
    batch.begin();

    player.draw(batch);

    batch.setProjectionMatrix(camera.combined);
    //        player.draw(batch);

    EntityManager.draw(Gdx.graphics.getDeltaTime(), batch);
    //        batch.draw(tex, w, w);
    batch.end();
    batch.dispose();
}

From source file:javagdxdungeon.NodeMap.java

public void DrawSections(OrthographicCamera camera) {
    shapeRenderer.setProjectionMatrix(camera.combined);
    shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
    shapeRenderer.setColor(0, 1, 0, 1);//from www  .j ava 2  s . c om
    SpriteBatch batch;
    String info;
    BitmapFont font;
    batch = new SpriteBatch();
    font = new BitmapFont();
    batch.setProjectionMatrix(camera.combined); //  #2
    batch.begin(); //begin?end??draw????
    batch.setColor(1, 1, 1, 1);
    float DrawMult = 5.0f;
    for (Iterator<Node> iterator = NodeList.iterator(); iterator.hasNext();) {
        Node node = iterator.next();
        info = String.format("section%d(%d,%d,%d,%d)" + node.LinkDump(), node.SectionNumber, node.x0, node.y0,
                node.x1, node.y1);
        shapeRenderer.box(node.x0 * DrawMult, node.y0 * DrawMult, 0, (node.x1 - node.x0) * DrawMult,
                (node.y1 - node.y0) * DrawMult, 0);
        font.draw(batch, info, 0, -20 * NodeList.indexOf(node));
        for (Iterator<LinkedStatus> iterator2 = node.LinkedNodeList.iterator(); iterator2.hasNext();) {
            LinkedStatus linked = iterator2.next();
            if (linked.IsActive == true)
                shapeRenderer.line((node.x0 + node.x1) * DrawMult / 2, (node.y0 + node.y1) * DrawMult / 2,
                        (linked.LinkingNode.x0 + linked.LinkingNode.x1) * DrawMult / 2,
                        (linked.LinkingNode.y0 + linked.LinkingNode.y1) * DrawMult / 2);
        }
    }
    batch.end();
    shapeRenderer.end();
    batch.dispose();
}

From source file:me.scarlet.undertailor.manager.SpriteSheetManager.java

License:Open Source License

public void testSheet(String sheetName) {
    SpriteSheetWrapper sheetRef = this.sheets.get(sheetName);
    SpriteSheet sheet = sheetRef.getReference(this);
    SpriteBatch batch = new SpriteBatch();
    batch.begin();//from w ww. j  ava2  s. c  o m
    int lastSize = 0;
    for (int i = 0; i < sheet.getSprites().length; i++) {
        if (i != 0) {
            lastSize += sheet.getSprite(i).getTextureRegion().getRegionWidth() * 2;
        }

        sheet.getSprite(i).draw(40 + lastSize, 35, 2.0F);
    }

    batch.end();
    batch.dispose();
    sheetRef.removeReference(this);
}