@Override public void resize (int width, int height) { // handling resizing is simple, just set the camera to ortho again camera.setToOrtho(true, width, height); }
@Override public void resize (int width, int height) { cam.setToOrtho(false, width, height); }
/** Sets this camera to an orthographic projection using a viewport fitting the screen resolution, centered at * (Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2), with the y-axis pointing up or down. * @param yDown whether y should be pointing down */ public void setToOrtho (boolean yDown) { setToOrtho(yDown, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); }
@Override public void resize (int width, int height) { cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); }
/** Sets this camera to an orthographic projection using a viewport fitting the screen resolution, centered at * (Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2), with the y-axis pointing up or down. * @param yDown whether y should be pointing down */ public void setToOrtho (boolean yDown) { setToOrtho(yDown, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); }
@Override public void resize (int width, int height) { super.resize(width, height); camera.setToOrtho(true, width, height); spriteBatch.setTransformMatrix(camera.view); spriteBatch.setProjectionMatrix(camera.projection); }
@Override public void resize (int width, int height) { Gdx.gl.glViewport(0, 0, width, height); if (pixelsPerMeter.getValue() <= 0) { pixelsPerMeter.setValue(1); } worldCamera.setToOrtho(false, width / pixelsPerMeter.getValue(), height / pixelsPerMeter.getValue()); worldCamera.update(); textCamera.setToOrtho(true, width, height); textCamera.update(); effect.setPosition(worldCamera.viewportWidth / 2, worldCamera.viewportHeight / 2); }
@Override public void resize (int width, int height) { Gdx.gl.glViewport(0, 0, width, height); if (pixelsPerMeter.getValue() <= 0) { pixelsPerMeter.setValue(1); } worldCamera.setToOrtho(false, width / pixelsPerMeter.getValue(), height / pixelsPerMeter.getValue()); worldCamera.update(); textCamera.setToOrtho(true, width, height); textCamera.update(); effect.setPosition(worldCamera.viewportWidth / 2, worldCamera.viewportHeight / 2); }
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); }
@Override public void create () { Pixmap pixmap = new Pixmap(16, 16, Pixmap.Format.RGBA8888); pixmap.setColor(Color.BLUE); pixmap.fill(); pixmap.setColor(Color.RED); pixmap.drawLine(0, 0, 15, 15); pixmap.drawLine(0, 15, 15, 0); tex = new Texture(pixmap); batch = new SpriteBatch(); cam = new OrthographicCamera(); cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); }
@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 AtlasTmxMapLoader().load("data/maps/tiled-atlas-processed/test.tmx"); renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f); }
@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 TmxMapLoader().load("data/maps/tiled/super-koalio/level1.tmx"); renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f); }
@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); }
@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.position.set(10.0f, 2.5f, 0.0f); camera.update(); cameraController = new OrthoCamController(camera); Gdx.input.setInputProcessor(cameraController); font = new BitmapFont(); batch = new SpriteBatch(); // These two maps should appear identical -- a ring of grass with water inside and out. // The original is correct, without the bug fix to TiledMapTileSets.java that acompanies // this test, the latter appears as all grass. // map = new TmxMapLoader().load("data/maps/tiled/external-tilesets/test_original.tmx"); map = new TmxMapLoader().load("data/maps/tiled/external-tilesets/test_extended.tmx"); renderer = new IsometricTiledMapRenderer(map, 1f / 32f); }
@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); }
@Override public void create () { // load the koala frames, split them, and assign them to Animations koalaTexture = new Texture("data/maps/tiled/super-koalio/koalio.png"); TextureRegion[] regions = TextureRegion.split(koalaTexture, 18, 26)[0]; stand = new Animation(0, regions[0]); jump = new Animation(0, regions[1]); walk = new Animation(0.15f, regions[2], regions[3], regions[4]); walk.setPlayMode(Animation.PlayMode.LOOP_PINGPONG); // figure out the width and height of the koala for collision // detection and rendering by converting a koala frames pixel // size into world units (1 unit == 16 pixels) Koala.WIDTH = 1 / 16f * regions[0].getRegionWidth(); Koala.HEIGHT = 1 / 16f * regions[0].getRegionHeight(); // load the map, set the unit scale to 1/16 (1 unit == 16 pixels) map = new TmxMapLoader().load("data/maps/tiled/super-koalio/level1.tmx"); renderer = new OrthogonalTiledMapRenderer(map, 1 / 16f); // create an orthographic camera, shows us 30x20 units of the world camera = new OrthographicCamera(); camera.setToOrtho(false, 30, 20); camera.update(); // create the Koala we want to move around the world koala = new Koala(); koala.position.set(20, 20); debugRenderer = new ShapeRenderer(); }
@Override public void create () { FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/unbom.ttf")); FreeTypeFontParameter parameter = new FreeTypeFontParameter(); parameter.size = 18; parameter.characters = "í•œêµì–´/ì¡°ì„ ï¿½?"; koreanFont = generator.generateFont(parameter); generator.dispose(); parameter.characters = FreeTypeFontGenerator.DEFAULT_CHARS; generator = new FreeTypeFontGenerator(Gdx.files.internal("data/russkij.ttf")); cyrillicFont = generator.generateFont(parameter); generator.dispose(); parameter.characters = "วรณยุ�?ต์"; generator = new FreeTypeFontGenerator(Gdx.files.internal("data/garuda.ttf")); thaiFont = generator.generateFont(parameter); generator.dispose(); batch = new SpriteBatch(); cam = new OrthographicCamera(); cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.update(); }
@Override public void render () { Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); batch.setProjectionMatrix(camera.combined); batch.begin(); float x = 10; float y = Gdx.graphics.getHeight() - 10; int renderCalls = 0; // NOTE: Before production release on mobile, you should cache the array from values() // inside the Enum in order to reduce allocations in the render loop. for (FontStyle style : FontStyle.values()) { for (FontSize size : FontSize.values()) { BitmapFont fnt = getFont(style, size); fnt.draw(batch, style.name() + " " + size.size + "pt: The quick brown fox jumps over the lazy dog", x, y); y -= fnt.getLineHeight() + 10; } y -= 20; } BitmapFont font = getFont(FontStyle.Regular, FontSize.Medium); font.draw(batch, text, 10, font.getCapHeight() + 10); // draw all glyphs in background batch.setColor(1f, 1f, 1f, 0.15f); batch.draw(regions.first(), 0, 0); batch.setColor(1f, 1f, 1f, 1f); batch.end(); }
@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); }
@Override public void create () { float w = Gdx.graphics.getWidth(); float h = Gdx.graphics.getHeight(); camera = new OrthographicCamera(); camera.setToOrtho(false, (w / h) * 20, 20); camera.position.set(10.0f, 2.5f, 0.0f); camera.update(); cameraController = new OrthoCamController(camera); Gdx.input.setInputProcessor(cameraController); font = new BitmapFont(); batch = new SpriteBatch(); map = new TmxMapLoader().load("data/maps/tiled/grouplayertest.tmx"); renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f); testMapProperty(map.getLayers().get("group1Visible"), true, 1f, 32, 0, true); MapGroupLayer group1Visible = (MapGroupLayer)map.getLayers().get("group1Visible"); testMapProperty(group1Visible.getLayers().get("group1ChildGroup"), true, 1f, 32, 0, true); testMapProperty(group1Visible.getLayers().get("group1ChildVisible"), true, 1f, 0, 0, false); testMapProperty(group1Visible.getLayers().get("group1ChildNotVisible"), false, 1f, 32, 0, false); testMapProperty(map.getLayers().get("group2NotVisible"), false, 1f, 0, 0, true); testMapProperty(map.getLayers().get("Layer1"), true, 1f, 0, 0, false); }