Example usage for com.badlogic.gdx.graphics.g2d SpriteCache endCache

List of usage examples for com.badlogic.gdx.graphics.g2d SpriteCache endCache

Introduction

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

Prototype

public int endCache() 

Source Link

Document

Ends the definition of a cache, returning the cache ID to be used with #draw(int) .

Usage

From source file:com.badlydrawngames.veryangryrobots.WorldView.java

License:Apache License

private int createWallsAndDoors(SpriteCache sc) {
    // Walls and doors never move, so we put them into a sprite cache.
    sc.clear();//from w  w w  .  ja v  a  2  s  .  c om
    sc.beginCache();
    sc.setColor(Color.BLUE);
    Array<Rectangle> rects = world.getWallRects();
    for (int i = 0; i < rects.size; i++) {
        Rectangle rect = rects.get(i);
        sc.add(Assets.pureWhiteTextureRegion, rect.x, rect.y, rect.width, rect.height);
    }
    sc.setColor(1, 1, 0, 1);
    rects = world.getDoorRects();
    for (int i = 0; i < rects.size; i++) {
        Rectangle rect = rects.get(i);
        sc.add(Assets.pureWhiteTextureRegion, rect.x, rect.y, rect.width, rect.height);
    }
    return sc.endCache();
}