@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); }
public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.setProjectionMatrix(sceneMatrix); batch.begin(); renderSprite(); batch.end(); batch.setProjectionMatrix(textMatrix); batch.begin(); font.draw(batch, modeString + " fps:" + Gdx.graphics.getFramesPerSecond(), 26, 65); batch.end(); }
@Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.setProjectionMatrix(cam.combined); batch.begin(); koreanFont.draw(batch, "한국어/조선�?", 0, 22); cyrillicFont.draw(batch, "cyrillic text", 0, 44); thaiFont.draw(batch, "วรรณยุ�?ต์", 0, 66); batch.end(); }
@Override public void render () { Gdx.gl.glClearColor(1, 0, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); cam.update(); batch.setProjectionMatrix(cam.combined); batch.begin(); batch.draw(tex, 1, 1); batch.end(); } }
@Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); controller.update(); camera.update(); batch.setProjectionMatrix(camera.combined); batch.begin(); batch.draw(texture, 0, 0, texture.getWidth() * 2, texture.getHeight() * 2); batch.end(); }
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); }
@Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); batch.setProjectionMatrix(camera.combined); batch.begin(); batch.draw(img2, -100, 0); batch.draw(img1, 0, 0); batch.end(); batch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); batch.begin(); font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond(), 0, 30); batch.end(); }
batch.setProjectionMatrix(camera.calculateParallaxMatrix(0, 0)); batch.disableBlending(); batch.begin(); batch.setProjectionMatrix(camera.calculateParallaxMatrix(0.5f, 1)); batch.begin(); batch.draw(layers[1], -512, -160); batch.setProjectionMatrix(camera.calculateParallaxMatrix(1f, 1)); batch.begin(); for (int i = 0; i < 9; i++) {
@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(); }
batch.setProjectionMatrix(cam.combined); batch.begin(); batch.draw(region, cam.position.x - texture.getWidth() / 2, cam.position.y - texture.getHeight() / 2,
@Override public void render () { // clear the screen, update the camera and make the sprite batch // use its matrices. Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); batch.setProjectionMatrix(camera.combined); // render all the things, we render in a y-down // cartesian coordinate system batch.begin(); // drawing a region, x and y will be the top left corner of the region, would be bottom left // with y-up. batch.draw(region, 20, 100); // drawing text, x and y will be the top left corner for text, same as with y-up font.draw(batch, "This is a test", 270, 100); // drawing regions from an atlas, x and y will be the top left corner. // you shouldn't call findRegion every frame, cache the result. batch.draw(atlas.findRegion("badlogicsmall"), 360, 100); // drawing a sprite created from an atlas, FIXME wut?! AtlasSprite#setPosition seems to be wrong sprite.setColor(Color.RED); sprite.draw(batch); // finally we draw our current touch/mouse coordinates font.draw(batch, Gdx.input.getX() + ", " + Gdx.input.getY(), 0, 0); batch.end(); // tell the stage to act and draw itself stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); }
public void render () { batch.setProjectionMatrix(camera.projection); batch.setTransformMatrix(camera.view);
spriteBatch.setProjectionMatrix(worldCamera.combined); shapeRenderer.setProjectionMatrix(ParticleEditor.this.worldCamera.combined); if (renderGridCheckBox.isSelected()) { spriteBatch.setProjectionMatrix(textCamera.combined);
spriteBatch.setProjectionMatrix(worldCamera.combined); shapeRenderer.setProjectionMatrix(ParticleEditor.this.worldCamera.combined); if (renderGridCheckBox.isSelected()) { spriteBatch.setProjectionMatrix(textCamera.combined);
@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 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(packer.getPages().first().getTexture(), 0, 0); batch.setColor(1f, 1f, 1f, 1f); batch.end(); }
orthoCamera.viewportHeight = ph; orthoCamera.update(); batch.setProjectionMatrix(orthoCamera.combined); batch.begin(); float s = 0.1f + 0.5f * (1 + MathUtils.sinDeg(time * 90.0f));
@Override public void create () { Gdx.input.setInputProcessor(new InputAdapter() { public boolean touchDown (int x, int y, int pointer, int newParam) { renderMode = (renderMode + 1) % 4; return false; } }); spriteBatch = new SpriteBatch(); spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, 0, 1)); texture = new Texture(Gdx.files.internal("data/badlogic.jpg")); logoSprite = new Sprite(texture); logoSprite.flip(false, true); logoSprite.setPosition(0, 320 - 256); logoSprite.setColor(1, 1, 1, 0.5f); font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), Gdx.files.internal("data/verdana39.png"), true); cache1 = font.newFontCache(); cache2 = font.newFontCache(); cache3 = font.newFontCache(); cache4 = font.newFontCache(); cache5 = font.newFontCache(); createCaches("cached", cache1, cache2, cache3, cache4, cache5); font.getData().setScale(1.33f); cacheScaled1 = font.newFontCache(); cacheScaled2 = font.newFontCache(); cacheScaled3 = font.newFontCache(); cacheScaled4 = font.newFontCache(); cacheScaled5 = font.newFontCache(); createCaches("cache scaled", cacheScaled1, cacheScaled2, cacheScaled3, cacheScaled4, cacheScaled5); }
spriteBatch.setProjectionMatrix(spriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); spriteBatch.begin();
camera.update(); shapeRenderer.setProjectionMatrix(camera.combined); batch.setProjectionMatrix(camera.combined); shapeRenderer.setColor(Color.BLUE); Gdx.gl20.glLineWidth(2);