Search in sources :

Example 96 with SpriteBatch

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

the class AtlasIssueTest method create.

public void create() {
    batch = new SpriteBatch();
    batch.setProjectionMatrix(new Matrix4().setToOrtho2D(0, 0, 855, 480));
    atlas = new TextureAtlas(Gdx.files.internal("data/issue_pack"), Gdx.files.internal("data/"));
    sprite = atlas.createSprite("map");
    font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false);
    Gdx.gl.glClearColor(0, 1, 0, 1);
}
Also used : TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 97 with SpriteBatch

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

the class NoncontinuousRenderingTest method create.

@Override
public void create() {
    batch = new SpriteBatch();
    texture = new Texture("data/badlogic.jpg");
    region = new TextureRegion(texture);
    stage = new Stage(new ScreenViewport(), batch);
    Gdx.input.setInputProcessor(stage);
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    skin.add("default", font = new BitmapFont(Gdx.files.internal("data/arial-32.fnt"), false));
    populateTable();
    Gdx.graphics.setContinuousRendering(false);
    Gdx.graphics.requestRendering();
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 98 with SpriteBatch

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

the class ParallaxTest method create.

@Override
public void create() {
    Texture texture = new Texture(Gdx.files.internal("data/layers.png"));
    layers = new TextureRegion[3];
    layers[0] = new TextureRegion(texture, 0, 0, 542, 363);
    layers[1] = new TextureRegion(texture, 0, 363, 1024, 149);
    layers[2] = new TextureRegion(texture, 547, 0, 224, 51);
    camera = new ParallaxCamera(480, 320);
    controller = new OrthoCamController(camera);
    Gdx.input.setInputProcessor(controller);
    batch = new SpriteBatch();
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 99 with SpriteBatch

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

the class ParticleEmittersTest method create.

@Override
public void create() {
    spriteBatch = new SpriteBatch();
    effect = new ParticleEffect();
    effect.load(Gdx.files.internal("data/singleTextureAllAdditive.p"), Gdx.files.internal("data"));
    effect.setPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
    effectPool = new ParticleEffectPool(effect, 20, 20);
    setupUI();
    InputProcessor inputProcessor = new InputAdapter() {

        public boolean touchDragged(int x, int y, int pointer) {
            if (latestEffect != null)
                latestEffect.setPosition(x, Gdx.graphics.getHeight() - y);
            return false;
        }

        public boolean touchDown(int x, int y, int pointer, int newParam) {
            latestEffect = effectPool.obtain();
            latestEffect.setEmittersCleanUpBlendFunction(!skipCleanup.isChecked());
            latestEffect.setPosition(x, Gdx.graphics.getHeight() - y);
            effects.add(latestEffect);
            return false;
        }
    };
    InputMultiplexer multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(ui);
    multiplexer.addProcessor(inputProcessor);
    Gdx.input.setInputProcessor(multiplexer);
}
Also used : ParticleEffect(com.badlogic.gdx.graphics.g2d.ParticleEffect) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) InputAdapter(com.badlogic.gdx.InputAdapter) ParticleEffectPool(com.badlogic.gdx.graphics.g2d.ParticleEffectPool) InputProcessor(com.badlogic.gdx.InputProcessor) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 100 with SpriteBatch

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

the class PathTest method create.

@Override
public void create() {
    renderer = new ImmediateModeRenderer20(false, false, 0);
    spriteBatch = new SpriteBatch();
    obj = new Sprite(new Texture(Gdx.files.internal("data/badlogicsmall.jpg")));
    obj.setSize(40, 40);
    obj.setOriginCenter();
    obj2 = new Sprite(new Texture(Gdx.files.internal("data/bobrgb888-32x32.png")));
    obj2.setSize(40, 40);
    obj2.setOriginCenter();
    // 96DP
    ZIGZAG_SCALE = Gdx.graphics.getDensity() * 96;
    float w = Gdx.graphics.getWidth() - obj.getWidth();
    float h = Gdx.graphics.getHeight() - obj.getHeight();
    paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(w, h)));
    paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(0, h), new Vector2(w, h)));
    paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(w, 0), new Vector2(0, h), new Vector2(w, h)));
    Vector2[] cp = new Vector2[] { new Vector2(0, 0), new Vector2(w * 0.25f, h * 0.5f), new Vector2(0, h), new Vector2(w * 0.5f, h * 0.75f), new Vector2(w, h), new Vector2(w * 0.75f, h * 0.5f), new Vector2(w, 0), new Vector2(w * 0.5f, h * 0.25f) };
    paths.add(new BSpline<Vector2>(cp, 3, true));
    paths.add(new CatmullRomSpline<Vector2>(cp, true));
    pathLength = paths.get(currentPath).approxLength(500);
    avg_speed = speed * pathLength;
    Gdx.input.setInputProcessor(this);
}
Also used : ImmediateModeRenderer20(com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Vector2(com.badlogic.gdx.math.Vector2) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

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