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); } });
/** Set the sprite's flip state regardless of current condition * @param x the desired horizontal flip state * @param y the desired vertical flip state */ public void setFlip (boolean x, boolean y) { boolean performX = false; boolean performY = false; if (isFlipX() != x) { performX = true; } if (isFlipY() != y) { performY = true; } flip(performX, performY); }
/** Set the sprite's flip state regardless of current condition * @param x the desired horizontal flip state * @param y the desired vertical flip state */ public void setFlip (boolean x, boolean y) { boolean performX = false; boolean performY = false; if (isFlipX() != x) { performX = true; } if (isFlipY() != y) { performY = true; } flip(performX, performY); }
@Override public void flip (boolean x, boolean y) { // Flip texture. if (region.rotate) super.flip(y, x); else super.flip(x, y); float oldOriginX = getOriginX(); float oldOriginY = getOriginY(); float oldOffsetX = region.offsetX; float oldOffsetY = region.offsetY; float widthRatio = getWidthRatio(); float heightRatio = getHeightRatio(); region.offsetX = originalOffsetX; region.offsetY = originalOffsetY; region.flip(x, y); // Updates x and y offsets. originalOffsetX = region.offsetX; originalOffsetY = region.offsetY; region.offsetX *= widthRatio; region.offsetY *= heightRatio; // Update position and origin with new offsets. translate(region.offsetX - oldOffsetX, region.offsetY - oldOffsetY); setOrigin(oldOriginX, oldOriginY); }
@Override public void flip (boolean x, boolean y) { // Flip texture. if (region.rotate) super.flip(y, x); else super.flip(x, y); float oldOriginX = getOriginX(); float oldOriginY = getOriginY(); float oldOffsetX = region.offsetX; float oldOffsetY = region.offsetY; float widthRatio = getWidthRatio(); float heightRatio = getHeightRatio(); region.offsetX = originalOffsetX; region.offsetY = originalOffsetY; region.flip(x, y); // Updates x and y offsets. originalOffsetX = region.offsetX; originalOffsetY = region.offsetY; region.offsetX *= widthRatio; region.offsetY *= heightRatio; // Update position and origin with new offsets. translate(region.offsetX - oldOffsetX, region.offsetY - oldOffsetY); setOrigin(oldOriginX, oldOriginY); }
@Override public void create () { if (spriteBatch != null) return; spriteBatch = new SpriteBatch(); Matrix4 transform = new Matrix4(); transform.setToTranslation(0, Gdx.graphics.getHeight(), 0); transform.mul(new Matrix4().setToScaling(1, -1, 1)); spriteBatch.setTransformMatrix(transform); pixS1 = new Pixmap(Gdx.files.getFileHandle("data/test4.png", Files.FileType.Internal)); pixS2 = new Pixmap(Gdx.files.getFileHandle("data/test3.png", Files.FileType.Internal)); pixD = new Pixmap(512, 1024, Pixmap.Format.RGBA8888); pixD.setBlending(Pixmap.Blending.SourceOver); pixD.setFilter(Pixmap.Filter.NearestNeighbour); pixD.drawPixmap(pixS1, 0, 0, 38, 76, 0, 0, 512, 1024); pixD.drawPixmap(pixS2, 0, 0, 38, 76, 0, 0, 512, 1024); logoSprite = new Sprite(new Texture(pixD)); logoSprite.flip(false, true); pixS1.dispose(); pixS2.dispose(); pixD.dispose(); }
@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); }
/** Creates a sprite from a glyph. * * @param ch * @return Sprite */ public Sprite getGlyphSprite (char ch) { Glyph glyph = Globals.g.font.getData().getGlyph(ch); Sprite s = new Sprite(Globals.g.font.getRegion().getTexture(), glyph.srcX,glyph.srcY,glyph.width, glyph.height); s.flip(false, true); s.setOrigin(glyph.width/2, glyph.height/2); return s; }
Texture tex = new Texture("path"); Sprite sprite = new Sprite(tex); sprite.flip(true, false);
/** Set the sprite's flip state regardless of current condition * @param x the desired horizontal flip state * @param y the desired vertical flip state */ public void setFlip (boolean x, boolean y) { boolean performX = false; boolean performY = false; if (isFlipX() != x) { performX = true; } if (isFlipY() != y) { performY = true; } flip(performX, performY); }
public TrackProgress () { lblAdvantage = new HudLabel(FontFace.CurseWhiteBig, "", false); lblAdvantageShown = false; lblAdvantage.setAlpha(0); texMask = Art.texCircleProgressMask; shProgress = ShaderLoader.fromFile("progress", "progress"); sprAdvantage = new Sprite(Art.texCircleProgress); sprAdvantage.flip(false, true); flipped = false; sprProgress = new Sprite(Art.texRadLinesProgress); sprProgress.flip(false, true); }
@Override public void flip (boolean x, boolean y) { // Flip texture. if (region.rotate) super.flip(y, x); else super.flip(x, y); float oldOriginX = getOriginX(); float oldOriginY = getOriginY(); float oldOffsetX = region.offsetX; float oldOffsetY = region.offsetY; float widthRatio = getWidthRatio(); float heightRatio = getHeightRatio(); region.offsetX = originalOffsetX; region.offsetY = originalOffsetY; region.flip(x, y); // Updates x and y offsets. originalOffsetX = region.offsetX; originalOffsetY = region.offsetY; region.offsetX *= widthRatio; region.offsetY *= heightRatio; // Update position and origin with new offsets. translate(region.offsetX - oldOffsetX, region.offsetY - oldOffsetY); setOrigin(oldOriginX, oldOriginY); }
public WrongWay () { sign = new Sprite(Art.wrongWay); float scale = 0.4f; w = Art.wrongWay.getWidth() * scale; h = Art.wrongWay.getHeight() * scale; offX = w / 2; offY = h / 2; sign.setSize(w, h); sign.setOrigin(offX, offY); sign.flip(false, true); bfAlpha = new BoxedFloat(0); isShown = false; }
public DriftBar () { seconds = 0; labelSeconds = new HudLabel(FontFace.CurseRedYellowNew, "s", false); labelSeconds.setAlpha(0); // texHalf = Art.texCircleProgressHalf; texHalfMask = Art.texCircleProgressHalfMask; w = texHalf.getWidth(); h = texHalf.getHeight(); offX = w / 2; offY = h / 2; shDriftSecs = ShaderLoader.fromFile("progress", "progress"); // drift seconds sprDriftSecs = new Sprite(texHalf); sprDriftSecs.flip(false, true); // drift strength driftStrength = new WindowedMean((int)(1 / 0.25f)); sprDriftStrength = new Sprite(texHalf); }