Search in sources :

Example 1 with ShapeRenderer

use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project libgdx by libgdx.

the class DelaunayTriangulatorTest method create.

public void create() {
    renderer = new ShapeRenderer();
    triangulate();
    System.out.println(seed);
    Gdx.input.setInputProcessor(new InputAdapter() {

        public boolean touchDown(int screenX, int screenY, int pointer, int button) {
            seed = MathUtils.random.nextLong();
            System.out.println(seed);
            triangulate();
            return true;
        }

        public boolean mouseMoved(int screenX, int screenY) {
            triangulate();
            return false;
        }
    });
}
Also used : InputAdapter(com.badlogic.gdx.InputAdapter) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 2 with ShapeRenderer

use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project libgdx by libgdx.

the class Box2DTest method create.

@Override
public void create() {
    // setup the camera. In Box2D we operate on a
    // meter scale, pixels won't do it. So we use
    // an orthographic camera with a viewport of
    // 48 meters in width and 32 meters in height.
    // We also position the camera so that it
    // looks at (0,16) (that's where the middle of the
    // screen will be located).
    camera = new OrthographicCamera(48, 32);
    camera.position.set(0, 16, 0);
    // next we setup the immediate mode renderer
    renderer = new ShapeRenderer();
    // next we create the box2d debug renderer
    debugRenderer = new Box2DDebugRenderer();
    // next we create a SpriteBatch and a font
    batch = new SpriteBatch();
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
    font.setColor(Color.RED);
    textureRegion = new TextureRegion(new Texture(Gdx.files.internal("data/badlogicsmall.jpg")));
    // next we create out physics world.
    createPhysicsWorld();
    // register ourselfs as an InputProcessor
    Gdx.input.setInputProcessor(this);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Box2DDebugRenderer(com.badlogic.gdx.physics.box2d.Box2DDebugRenderer) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 3 with ShapeRenderer

use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project libgdx by libgdx.

the class BitmapFontMetricsTest method create.

@Override
public void create() {
    spriteBatch = new SpriteBatch();
    atlas = new TextureAtlas("data/pack");
    smallFont = new BitmapFont();
    font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), atlas.findRegion("verdana39"), false);
    font = new BitmapFont(Gdx.files.internal("data/arial-32-pad.fnt"), false);
    renderer = new ShapeRenderer();
    renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix());
}
Also used : TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 4 with ShapeRenderer

use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project libgdx by libgdx.

the class TiledMapLayerOffsetTest method create.

@Override
public void create() {
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, (w / h) * 10, 10);
    camera.zoom = 2;
    camera.update();
    cameraController = new OrthoCamController(camera);
    Gdx.input.setInputProcessor(cameraController);
    font = new BitmapFont();
    batch = new SpriteBatch();
    shapeRenderer = new ShapeRenderer();
    assetManager = new AssetManager();
    assetManager.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver()));
    assetManager.load(MAP_ORTHO, TiledMap.class);
    assetManager.load(MAP_ISO, TiledMap.class);
    assetManager.load(MAP_ISO_STAG, TiledMap.class);
    assetManager.load(MAP_HEX_X, TiledMap.class);
    assetManager.load(MAP_HEX_Y, TiledMap.class);
    assetManager.finishLoading();
    map = assetManager.get(MAP_ORTHO);
    renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
Also used : OrthogonalTiledMapRenderer(com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer) TmxMapLoader(com.badlogic.gdx.maps.tiled.TmxMapLoader) AssetManager(com.badlogic.gdx.assets.AssetManager) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 5 with ShapeRenderer

use of com.badlogic.gdx.graphics.glutils.ShapeRenderer in project libgdx by libgdx.

the class TextureAtlasTest method create.

public void create() {
    batch = new SpriteBatch();
    renderer = new ShapeRenderer();
    atlas = new TextureAtlas(Gdx.files.internal("data/pack"));
    jumpAtlas = new TextureAtlas(Gdx.files.internal("data/jump.txt"));
    jumpAnimation = new Animation(0.25f, jumpAtlas.findRegions("ALIEN_JUMP_"));
    badlogic = atlas.createSprite("badlogicslice");
    badlogic.setPosition(50, 50);
    // badlogicSmall = atlas.createSprite("badlogicsmall");
    badlogicSmall = atlas.createSprite("badlogicsmall-rotated");
    badlogicSmall.setPosition(10, 10);
    AtlasRegion region = atlas.findRegion("badlogicsmall");
    System.out.println("badlogicSmall original size: " + region.originalWidth + ", " + region.originalHeight);
    System.out.println("badlogicSmall packed size: " + region.packedWidth + ", " + region.packedHeight);
    star = atlas.createSprite("particle-star");
    star.setPosition(10, 70);
    font = new BitmapFont(Gdx.files.internal("data/font.fnt"), atlas.findRegion("font"), false);
    Gdx.gl.glClearColor(0, 1, 0, 1);
    Gdx.input.setInputProcessor(new InputAdapter() {

        public boolean keyUp(int keycode) {
            if (keycode == Keys.UP) {
                badlogicSmall.flip(false, true);
            } else if (keycode == Keys.RIGHT) {
                badlogicSmall.flip(true, false);
            } else if (keycode == Keys.LEFT) {
                badlogicSmall.setSize(512, 512);
            } else if (keycode == Keys.DOWN) {
                badlogicSmall.rotate90(true);
            }
            return super.keyUp(keycode);
        }
    });
}
Also used : TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) InputAdapter(com.badlogic.gdx.InputAdapter) Animation(com.badlogic.gdx.graphics.g2d.Animation) AtlasRegion(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Aggregations

ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)31 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)16 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)12 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)10 Texture (com.badlogic.gdx.graphics.Texture)8 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)7 Stage (com.badlogic.gdx.scenes.scene2d.Stage)5 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)5 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)5 InputAdapter (com.badlogic.gdx.InputAdapter)4 AssetManager (com.badlogic.gdx.assets.AssetManager)4 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)3 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)3 Model (com.badlogic.gdx.graphics.g3d.Model)3 TmxMapLoader (com.badlogic.gdx.maps.tiled.TmxMapLoader)3 Animation (com.badlogic.gdx.graphics.g2d.Animation)2 BitmapFontCache (com.badlogic.gdx.graphics.g2d.BitmapFontCache)2 FreeTypeFontGenerator (com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator)2 FreeTypeFontParameter (com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter)2 OrthogonalTiledMapRenderer (com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer)2