Search in sources :

Example 16 with OrthographicCamera

use of com.badlogic.gdx.graphics.OrthographicCamera in project libgdx by libgdx.

the class TideMapAssetManagerTest 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();
    assetManager = new AssetManager();
    assetManager.setLoader(TiledMap.class, new TideMapLoader(new InternalFileHandleResolver()));
    assetManager.load("data/maps/tide/Map01.tide", TiledMap.class);
    assetManager.finishLoading();
    map = assetManager.get("data/maps/tide/Map01.tide");
    renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
Also used : OrthogonalTiledMapRenderer(com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer) 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) TideMapLoader(com.badlogic.gdx.maps.tiled.TideMapLoader) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 17 with OrthographicCamera

use of com.badlogic.gdx.graphics.OrthographicCamera in project libgdx by libgdx.

the class TideMapDirectLoaderTest 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.update();
    cameraController = new OrthoCamController(camera);
    Gdx.input.setInputProcessor(cameraController);
    font = new BitmapFont();
    batch = new SpriteBatch();
    map = new TideMapLoader().load("data/maps/tide/Map01.tide");
    renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
Also used : OrthogonalTiledMapRenderer(com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) TideMapLoader(com.badlogic.gdx.maps.tiled.TideMapLoader) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 18 with OrthographicCamera

use of com.badlogic.gdx.graphics.OrthographicCamera 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, 15, 0);
    // create the debug renderer
    renderer = new Box2DDebugRenderer();
    // create the world
    world = new World(new Vector2(0, -10), true);
    // we also need an invisible zero size ground body
    // to which we can connect the mouse joint
    BodyDef bodyDef = new BodyDef();
    groundBody = world.createBody(bodyDef);
    // call abstract method to populate the world
    createWorld(world);
    batch = new SpriteBatch();
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
}
Also used : Box2DDebugRenderer(com.badlogic.gdx.physics.box2d.Box2DDebugRenderer) Vector2(com.badlogic.gdx.math.Vector2) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) World(com.badlogic.gdx.physics.box2d.World) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) BodyDef(com.badlogic.gdx.physics.box2d.BodyDef) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 19 with OrthographicCamera

use of com.badlogic.gdx.graphics.OrthographicCamera in project libgdx by libgdx.

the class MoveSpriteExample method create.

public void create() {
    // create a SpriteBatch with which to render the sprite
    batch = new SpriteBatch();
    // load the sprite's texture. note: usually you have more than
    // one sprite in a texture, see {@see TextureAtlas} and {@see TextureRegion}.
    texture = new Texture(Gdx.files.internal("data/bobargb8888-32x32.png"));
    // create an {@link OrthographicCamera} which is used to transform
    // touch coordinates to world coordinates.
    camera = new OrthographicCamera();
    // we want the camera to setup a viewport with pixels as units, with the
    // y-axis pointing upwards. The origin will be in the lower left corner
    // of the screen.
    camera.setToOrtho(false);
}
Also used : OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 20 with OrthographicCamera

use of com.badlogic.gdx.graphics.OrthographicCamera in project libgdx by libgdx.

the class FreeTypeTest method create.

@Override
public void create() {
    boolean flip = false;
    batch = new SpriteBatch();
    if (flip) {
        OrthographicCamera cam = new OrthographicCamera();
        cam.setToOrtho(flip);
        cam.update();
        batch.setProjectionMatrix(cam.combined);
    }
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), flip);
    FileHandle fontFile = Gdx.files.internal("data/arial.ttf");
    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
    FreeTypeFontParameter parameter = new FreeTypeFontParameter();
    parameter.size = 15;
    parameter.flip = flip;
    parameter.genMipMaps = true;
    // parameter.shadowOffsetX = 1;
    // parameter.shadowOffsetY = 1;
    // parameter.shadowColor = Color.GREEN;
    // parameter.borderWidth = 1f;
    // parameter.borderColor = Color.PURPLE;
    FreeTypeBitmapFontData fontData = generator.generateData(parameter);
    ftFont = generator.generateFont(parameter);
    generator.dispose();
}
Also used : FreeTypeFontGenerator(com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator) FreeTypeFontParameter(com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter) FileHandle(com.badlogic.gdx.files.FileHandle) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) FreeTypeBitmapFontData(com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeBitmapFontData) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Aggregations

OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)50 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)32 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)21 Texture (com.badlogic.gdx.graphics.Texture)20 OrthoCamController (com.badlogic.gdx.tests.utils.OrthoCamController)15 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)10 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)10 OrthogonalTiledMapRenderer (com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer)7 TmxMapLoader (com.badlogic.gdx.maps.tiled.TmxMapLoader)6 Box2DDebugRenderer (com.badlogic.gdx.physics.box2d.Box2DDebugRenderer)6 AssetManager (com.badlogic.gdx.assets.AssetManager)5 InternalFileHandleResolver (com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver)4 Pixmap (com.badlogic.gdx.graphics.Pixmap)4 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)3 PolygonSpriteBatch (com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch)3 Vector2 (com.badlogic.gdx.math.Vector2)3 World (com.badlogic.gdx.physics.box2d.World)3 Stage (com.badlogic.gdx.scenes.scene2d.Stage)3 InputAdapter (com.badlogic.gdx.InputAdapter)2 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)2