Search in sources :

Example 16 with SpriteBatch

use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.

the class AssetManagerTest method create.

public void create() {
    Gdx.app.setLogLevel(Application.LOG_ERROR);
    Resolution[] resolutions = { new Resolution(320, 480, ".320480"), new Resolution(480, 800, ".480800"), new Resolution(480, 856, ".480854") };
    ResolutionFileResolver resolver = new ResolutionFileResolver(new InternalFileHandleResolver(), resolutions);
    manager = new AssetManager();
    manager.setLoader(Texture.class, new TextureLoader(resolver));
    manager.setErrorListener(this);
    load();
    Texture.setAssetManager(manager);
    batch = new SpriteBatch();
    font = new BitmapFont(Gdx.files.internal("data/font.fnt"), false);
}
Also used : ResolutionFileResolver(com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver) AssetManager(com.badlogic.gdx.assets.AssetManager) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) TextureLoader(com.badlogic.gdx.assets.loaders.TextureLoader) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Resolution(com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution)

Example 17 with SpriteBatch

use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.

the class AccelerometerTest method create.

@Override
public void create() {
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
    batch = new SpriteBatch();
}
Also used : BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 18 with SpriteBatch

use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.

the class FrameBufferTest method create.

@Override
public void create() {
    mesh = new Mesh(true, 3, 0, new VertexAttribute(Usage.Position, 3, "a_Position"), new VertexAttribute(Usage.ColorPacked, 4, "a_Color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));
    float c1 = Color.toFloatBits(255, 0, 0, 255);
    float c2 = Color.toFloatBits(255, 0, 0, 255);
    float c3 = Color.toFloatBits(0, 0, 255, 255);
    mesh.setVertices(new float[] { -0.5f, -0.5f, 0, c1, 0, 0, 0.5f, -0.5f, 0, c2, 1, 0, 0, 0.5f, 0, c3, 0.5f, 1 });
    stencilMesh = new Mesh(true, 3, 0, new VertexAttribute(Usage.Position, 3, "a_Position"), new VertexAttribute(Usage.ColorPacked, 4, "a_Color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));
    stencilMesh.setVertices(new float[] { -0.5f, 0.5f, 0, c1, 0, 0, 0.5f, 0.5f, 0, c2, 1, 0, 0, -0.5f, 0, c3, 0.5f, 1 });
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    spriteBatch = new SpriteBatch();
    frameBuffer = new FrameBuffer(Format.RGB565, 128, 128, false);
    stencilFrameBuffer = new FrameBuffer(Format.RGB565, 128, 128, false, true);
    createShader(Gdx.graphics);
}
Also used : VertexAttribute(com.badlogic.gdx.graphics.VertexAttribute) Mesh(com.badlogic.gdx.graphics.Mesh) FrameBuffer(com.badlogic.gdx.graphics.glutils.FrameBuffer) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 19 with SpriteBatch

use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.

the class VibratorTest method create.

@Override
public void create() {
    batch = new SpriteBatch();
    font = new BitmapFont();
}
Also used : BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 20 with SpriteBatch

use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.

the class TiledMapBench method create.

@Override
public void create() {
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, (w / h) * 320, 320);
    camera.update();
    cameraController = new OrthoCamController(camera);
    Gdx.input.setInputProcessor(cameraController);
    font = new BitmapFont();
    batch = new SpriteBatch();
    {
        tiles = new Texture(Gdx.files.internal("data/maps/tiled/tiles.png"));
        TextureRegion[][] splitTiles = TextureRegion.split(tiles, 32, 32);
        map = new TiledMap();
        MapLayers layers = map.getLayers();
        for (int l = 0; l < 20; l++) {
            TiledMapTileLayer layer = new TiledMapTileLayer(150, 100, 32, 32);
            for (int x = 0; x < 150; x++) {
                for (int y = 0; y < 100; y++) {
                    int ty = (int) (Math.random() * splitTiles.length);
                    int tx = (int) (Math.random() * splitTiles[ty].length);
                    Cell cell = new Cell();
                    cell.setTile(new StaticTiledMapTile(splitTiles[ty][tx]));
                    layer.setCell(x, y, cell);
                }
            }
            layers.add(layer);
        }
    }
    renderer = new OrthogonalTiledMapRenderer(map);
}
Also used : OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) OrthogonalTiledMapRenderer(com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer) TiledMapTileLayer(com.badlogic.gdx.maps.tiled.TiledMapTileLayer) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) TiledMap(com.badlogic.gdx.maps.tiled.TiledMap) Cell(com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell) MapLayers(com.badlogic.gdx.maps.MapLayers)

Aggregations

SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)121 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)64 Texture (com.badlogic.gdx.graphics.Texture)59 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)32 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)22 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)16 Pixmap (com.badlogic.gdx.graphics.Pixmap)15 AssetManager (com.badlogic.gdx.assets.AssetManager)13 Stage (com.badlogic.gdx.scenes.scene2d.Stage)13 OrthoCamController (com.badlogic.gdx.tests.utils.OrthoCamController)13 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)11 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)10 InputAdapter (com.badlogic.gdx.InputAdapter)9 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)9 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)8 InternalFileHandleResolver (com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver)7 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)7 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)7 ShaderProgram (com.badlogic.gdx.graphics.glutils.ShaderProgram)7 Vector2 (com.badlogic.gdx.math.Vector2)7