Java 类com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment 实例源码

项目:android-screen-recorder    文件:GameOver.java   
@Override
public void draw (float delta) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    viewMatrix.setToOrtho2D(0, 0, 480, 320);
    spriteBatch.setProjectionMatrix(viewMatrix);
    spriteBatch.setTransformMatrix(transformMatrix);
    spriteBatch.begin();
    spriteBatch.disableBlending();
    spriteBatch.setColor(Color.WHITE);
    spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false);
    spriteBatch.enableBlending();
    spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 256, 512, 256, false, false);
    String text = "It is the end my friend.\nTouch to continue!";
    TextBounds bounds = font.getMultiLineBounds(text);
    spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
    font.drawMultiLine(spriteBatch, text, 0, 160 + bounds.height / 2, 480, HAlignment.CENTER);
    spriteBatch.end();
}
项目:teavm-libgdx    文件:GameOver.java   
@Override
public void draw (float delta) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    viewMatrix.setToOrtho2D(0, 0, 480, 320);
    spriteBatch.setProjectionMatrix(viewMatrix);
    spriteBatch.setTransformMatrix(transformMatrix);
    spriteBatch.begin();
    spriteBatch.disableBlending();
    spriteBatch.setColor(Color.WHITE);
    spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false);
    spriteBatch.enableBlending();
    spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 256, 512, 256, false, false);
    String text = "It is the end my friend.\nTouch to continue!";
    TextBounds bounds = font.getMultiLineBounds(text);
    spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
    font.drawMultiLine(spriteBatch, text, 0, 160 + bounds.height / 2, 480, HAlignment.CENTER);
    spriteBatch.end();
}
项目:libgdxcn    文件:BitmapFontFlipTest.java   
private void createCaches (String type, BitmapFontCache cache1, BitmapFontCache cache2, BitmapFontCache cache3,
    BitmapFontCache cache4, BitmapFontCache cache5) {
    cache1.setText("(" + type + ")", 10, 320 - 66);

    String text = "Sphinx of black quartz,\njudge my vow.";
    cache2.setColor(Color.RED);
    cache2.setMultiLineText(text, 5, 320 - 300);

    text = "How quickly\ndaft jumping zebras vex.";
    cache3.setColor(Color.BLUE);
    cache3.setMultiLineText(text, 5, 320 - 200, 470, BitmapFont.HAlignment.CENTER);

    text = "Kerning: LYA moo";
    cache4.setText(text, 210, 320 - 66, 0, text.length() - 3);

    text = "Forsaking monastic tradition, twelve jovial friars gave\nup their vocation for a questionable existence on the flying trapeze.";
    cache5.setColor(red);
    cache5.setWrappedText(text, 0, 320 - 300, 480, HAlignment.CENTER);
}
项目:libgdxcn    文件:BitmapFontFlipTest.java   
private void renderNormal (String type) {
    String text = "Forsaking monastic tradition, twelve jovial friars gave\nup their vocation for a questionable existence on the flying trapeze.";
    font.setColor(red);
    font.drawWrapped(spriteBatch, text, 0, 320 - 300, 480, HAlignment.CENTER);

    font.setColor(Color.WHITE);
    font.draw(spriteBatch, "(" + type + ")", 10, 320 - 66);

    if (red.a > 0.6f) return;

    text = "Sphinx of black quartz,\njudge my vow.";
    font.setColor(Color.RED);
    font.drawMultiLine(spriteBatch, text, 5, 320 - 300);

    text = "How quickly\ndaft jumping zebras vex.";
    font.setColor(Color.BLUE);
    font.drawMultiLine(spriteBatch, text, 5, 320 - 200, 470, BitmapFont.HAlignment.RIGHT);

    text = "Kerning: LYA moo";
    font.setColor(Color.WHITE);
    font.draw(spriteBatch, text, 210, 320 - 66, 0, text.length() - 3);
}
项目:Protoman-vs-Megaman    文件:MegamanMenu.java   
@Override
public void render(SpriteBatch spriteBatch) {
    super.render(spriteBatch);

    spriteBatch.begin();
    font.drawWrapped(spriteBatch, menuTitle, 0, GameConstants.GAME_HEIGHT - 60, GameConstants.GAME_WIDTH, HAlignment.CENTER);

    spriteBatch.draw(megaman, getCurrentOption().getX() - megaman.getWidth() - 40, getCurrentOption().getY() + 20, megaman.getOriginX(), megaman.getOriginY(), megaman.getWidth(), megaman.getHeight(), megaman.getScaleX(), megaman.getScaleY(), megaman.getRotation());
    spriteBatch.draw(protoman, getCurrentOption().getX() + getCurrentOption().getWidth() + 40, getCurrentOption().getY() + 10, protoman.getOriginX(), protoman.getOriginY(), protoman.getWidth(), protoman.getHeight(), protoman.getScaleX(), protoman.getScaleY(), protoman.getRotation());
    spriteBatch.draw(missile, missileX, getCurrentOption().getY() + 24, missile.getOriginX(), missile.getOriginY(), missile.getWidth(), missile.getHeight(), missile.getScaleX(), missile.getScaleY(), missile.getRotation());
    spriteBatch.end();
}
项目:libgdxcn    文件:Label.java   
/** @param labelAlign Aligns all the text with the label widget.
 * @param lineAlign Aligns each line of text (left, right, or center).
 * @see Align */
public void setAlignment (int labelAlign, int lineAlign) {
    this.labelAlign = labelAlign;

    if ((lineAlign & Align.left) != 0)
        this.lineAlign = HAlignment.LEFT;
    else if ((lineAlign & Align.right) != 0)
        this.lineAlign = HAlignment.RIGHT;
    else
        this.lineAlign = HAlignment.CENTER;

    invalidate();
}
项目:libgdxcn    文件:IntegerBitmapFontTest.java   
private void fillCaches () {
    String text = "This is a TEST\nxahsdhwekjhasd23���$%$%/%&";
    singleLineCache.setColor(0, 0, 1, 1);
    singleLineCache.setText(text, 10.2f, 30.5f);
    multiLineCache.setColor(0, 0, 1, 1);
    multiLineCache.setMultiLineText(text, 10.5f, 180.5f, 200, HAlignment.CENTER);
    singleLineCacheNonInteger.setColor(0, 1, 0, 1);
    singleLineCacheNonInteger.setText(text, 10.2f, 30.5f);
    multiLineCacheNonInteger.setColor(0, 1, 0, 1);
    multiLineCacheNonInteger.setMultiLineText(text, 10.5f, 180.5f, 200, HAlignment.CENTER);
}
项目:bar    文件:Frame.java   
/**
 * Dibuja el boton con texto
 */
public void drawAll(){
    sb.setColor(1f, 1f, 1f, super.def.angleORalpha);
    sb.draw(showingTexture, def.x, def.y, srcX, srcY, w, h, 
            def.scaleXY, def.scaleXY, 0);
    font.drawWrapped(sb, text, def.x, def.y+textHeight, w, HAlignment.CENTER);
    sb.setColor(1f, 1f, 1f, 1f);
}
项目:ingress-indonesia-dev    文件:Label.java   
public void setAlignment(int paramInt1, int paramInt2)
{
  this.labelAlign = paramInt1;
  if ((paramInt2 & 0x8) != 0)
    this.lineAlign = BitmapFont.HAlignment.LEFT;
  while (true)
  {
    invalidate();
    return;
    if ((paramInt2 & 0x10) != 0)
      this.lineAlign = BitmapFont.HAlignment.RIGHT;
    else
      this.lineAlign = BitmapFont.HAlignment.CENTER;
  }
}
项目:ragnar    文件:WinScreen.java   
/**
     * Called every frame<br>
     * Steps physics and draws to bodies
     * @param delta time from last frame in seconds (used here)
     */
    @Override
    public void render(float delta) {
        super.render(delta);
        Gdx.gl.glClearColor(0, .69f, 1, 1);//Color of Valhalla
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        handleBarrierDeath();

        if (Gdx.input.isKeyJustPressed(Keys.BACK)) {
            game.setScreen(game.gameScreen);
        }



        stateTime += delta;
        world.step(1/60f, 8, 3);
        angel.update(delta);

        for (Meteor m : meteors) {
            m.update(delta, batch);
        }

        fontBatch.setProjectionMatrix(fontCamera.combined);
        fontBatch.begin();
//      Assets.ragnarFont.draw(fontBatch, "You Win Entrance to Valhalla", -fontCamera.viewportWidth / 4, fontCamera.viewportHeight / 4);
        Assets.ragnarFont.drawWrapped(fontBatch, "You Win Entrance to Valhalla", -fontCamera.viewportWidth * .375f, fontCamera.viewportHeight * .375f, fontCamera.viewportWidth * .75f, HAlignment.CENTER);
        Assets.scoreFont.drawWrapped(fontBatch, "Score " + (int)(game.gameScreen.timeInGame) + " seconds", -fontCamera.viewportWidth * .375f, -fontCamera.viewportHeight * .375f, fontCamera.viewportWidth * .75f, HAlignment.CENTER);
        fontBatch.end();

        angel.draw(stateTime, batch);
        batch.setProjectionMatrix(camera.combined);
        batch.begin();
        leftSidebar.draw(batch);
        rightSidebar.draw(batch);
        batch.end();

        //testMeteor.update(delta, batch);

        Ragnar.debugger.renderDebug(world, camera.combined);
    }
项目:libgdxcn    文件:BitmapFontCache.java   
/** Clears any cached glyphs and adds glyphs for the specified text, which may contain newlines (\n).
 * @see #addMultiLineText(CharSequence, float, float, float, HAlignment) */
public TextBounds setMultiLineText (CharSequence str, float x, float y) {
    clear();
    return addMultiLineText(str, x, y, 0, HAlignment.LEFT);
}
项目:libgdxcn    文件:BitmapFontCache.java   
/** Clears any cached glyphs and adds glyphs for the specified text, which may contain newlines (\n).
 * @see #addMultiLineText(CharSequence, float, float, float, HAlignment) */
public TextBounds setMultiLineText (CharSequence str, float x, float y, float alignmentWidth, HAlignment alignment) {
    clear();
    return addMultiLineText(str, x, y, alignmentWidth, alignment);
}
项目:libgdxcn    文件:BitmapFontCache.java   
/** Adds glyphs for the specified text, which may contain newlines (\n).
 * @see #addMultiLineText(CharSequence, float, float, float, HAlignment) */
public TextBounds addMultiLineText (CharSequence str, float x, float y) {
    return addMultiLineText(str, x, y, 0, HAlignment.LEFT);
}
项目:libgdxcn    文件:BitmapFontCache.java   
/** Clears any cached glyphs and adds glyphs for the specified text, which may contain newlines (\n) and is automatically
 * wrapped within the specified width.
 * @see #addWrappedText(CharSequence, float, float, float, HAlignment) */
public TextBounds setWrappedText (CharSequence str, float x, float y, float wrapWidth) {
    clear();
    return addWrappedText(str, x, y, wrapWidth, HAlignment.LEFT);
}
项目:libgdxcn    文件:BitmapFontCache.java   
/** Clears any cached glyphs and adds glyphs for the specified text, which may contain newlines (\n) and is automatically
 * wrapped within the specified width.
 * @see #addWrappedText(CharSequence, float, float, float, HAlignment) */
public TextBounds setWrappedText (CharSequence str, float x, float y, float wrapWidth, HAlignment alignment) {
    clear();
    return addWrappedText(str, x, y, wrapWidth, alignment);
}
项目:libgdxcn    文件:BitmapFontCache.java   
/** Adds glyphs for the specified text, which may contain newlines (\n) and is automatically wrapped within the specified width.
 * @see #addWrappedText(CharSequence, float, float, float, HAlignment) */
public TextBounds addWrappedText (CharSequence str, float x, float y, float wrapWidth) {
    return addWrappedText(str, x, y, wrapWidth, HAlignment.LEFT);
}
项目:libgdxcn    文件:BitmapFontTest.java   
@Override
public void render () {
    // red.a = (red.a + Gdx.graphics.getDeltaTime() * 0.1f) % 1;

    int viewHeight = Gdx.graphics.getHeight();

    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    spriteBatch.begin();

    String text = "Sphinx of black quartz, judge my vow.";
    font.setColor(Color.RED);

    float x = 100, y = 20;
    float alignmentWidth;

    if (false) {
        alignmentWidth = 0;
        font.drawMultiLine(spriteBatch, text, x, viewHeight - y, alignmentWidth, HAlignment.RIGHT);
    }

    if (false) {
        TextBounds bounds = font.getMultiLineBounds(text);
        alignmentWidth = bounds.width;
        font.drawMultiLine(spriteBatch, text, x, viewHeight - y, alignmentWidth, HAlignment.RIGHT);
    }

    if (true) {
        alignmentWidth = 280;
        // font.drawMultiLine(spriteBatch, text, x, viewHeight - y, alignmentWidth, HAlignment.RIGHT);
        font.drawWrapped(spriteBatch, text, x, viewHeight - y, alignmentWidth, HAlignment.RIGHT);
    }

    // 'R' and 'p' are in different pages
    String txt2 = "this font uses " + multiPageFont.getRegions().length + " texture pages: RpRpRpRpRpNM";
    spriteBatch.renderCalls = 0;

    // regular draw function
    multiPageFont.setColor(Color.BLUE);
    multiPageFont.draw(spriteBatch, txt2, 10, 100);

    // expert usage.. drawing with bitmap font cache
    BitmapFontCache cache = multiPageFont.getCache();
    cache.clear();
    cache.setColor(Color.BLACK);
    cache.setText(txt2, 10, 50);
    cache.setColors(Color.PINK, 3, 6);
    cache.setColors(Color.ORANGE, 9, 12);
    cache.setColors(Color.GREEN, 16, txt2.length());
    cache.draw(spriteBatch, 5, txt2.length() - 5);

    cache.clear();
    cache.setColor(Color.BLACK);
    float textX = 10;
    textX += cache.setText("[black] ", textX, 150).width;
    multiPageFont.setMarkupEnabled(true);
    textX += cache.addText("[[[PINK]pink[]] ", textX, 150).width;
    textX += cache.addText("[PERU][[peru] ", textX, 150).width;
    cache.setColor(Color.GREEN);
    textX += cache.addText("green ", textX, 150).width;
    textX += cache.addText("[#A52A2A]br[#A52A2ADF]ow[#A52A2ABF]n f[#A52A2A9F]ad[#A52A2A7F]in[#A52A2A5F]g o[#A52A2A3F]ut ",
        textX, 150).width;
    multiPageFont.setMarkupEnabled(false);

    cache.draw(spriteBatch);

    spriteBatch.end();
    // System.out.println(spriteBatch.renderCalls);

    renderer.begin(ShapeType.Line);
    renderer.setColor(Color.BLACK);
    renderer.rect(x, viewHeight - y, x + alignmentWidth, 300);
    renderer.end();

    stage.act(Gdx.graphics.getDeltaTime());
    stage.draw();
}
项目:libgdxcn    文件:IntegerBitmapFontTest.java   
private void drawTexts () {
    String text = "This is a TEST\nxahsdhwekjhasd23���$%$%/%&";
    font.draw(batch, text, 10.2f, 30.5f);
    font.drawMultiLine(batch, text, 10.5f, 120.5f);
    font.drawMultiLine(batch, text, 10.5f, 180.5f, 200, HAlignment.CENTER);
}
项目:bar    文件:Frame.java   
/**
 * Dibuja texto
 */
public void drawText(){
    sb.setColor(1f, 1f, 1f, super.def.angleORalpha);
    font.drawWrapped(sb, text, def.x, def.y+textHeight, w, HAlignment.CENTER);
    sb.setColor(1f, 1f, 1f, 1f);
}
项目:Horses-in-Space    文件:StartMenu.java   
@Override
public void render(float delta) {

    Gdx.gl.glClearColor(0, 0, 0, 1f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Drawing background
    this.stars.enableBlending();
    this.stars.begin();
    this.stars.draw(this.starsTexture, (screenWidth / 2)
            - (this.starsTexture.getWidth() / 2), (screenHeight / 2)
            - (this.starsTexture.getHeight() / 2));
    this.stars.end();

    AssetLoader.font.setColor(Color.valueOf("971abbff"));

    // Draw + fade in logo
    this.alpha += delta / 2.5;
    if (this.alpha >= 1) {
        this.logo.setColor(1, 1, 1, 1);
    } else {
        this.logo.setColor(1, 1, 1, this.alpha);
    }
    this.logo.enableBlending();
    this.logo.begin();
    this.logo.draw(this.logoTexture,
            (screenWidth / 2) - (this.logoTexture.getWidth() / 2),
            (screenHeight / 2) - (this.logoTexture.getHeight() / 2));

    // Creates flashing text
    if (!this.fadeIn) {
        this.textAlpha += delta;
    } else {
        this.textAlpha -= delta;
    }
    if (this.textAlpha >= 1) {
        this.fadeIn = true;

    } else if (this.textAlpha > 0.5) {
        AssetLoader.font.setColor(Color.valueOf("971abbff"));
    }
    if (this.textAlpha < 0) {
        this.fadeIn = false;

    }
    if (this.textAlpha < 0.5) {
        AssetLoader.font.setColor(Color.valueOf("971abb00"));

    }

    AssetLoader.font.drawWrapped(this.logo, this.startGame, 0, gameHeight,
            screenWidth, HAlignment.CENTER);
    this.logo.end();

    // Starts the game on touch or when Space is pressed
    if (Gdx.input.justTouched() || Gdx.input.isKeyPressed(Keys.SPACE)) {
        this.game.setScreen(new GameScreen());

        AssetLoader.font.setScale(.10f, -.10f);
        AssetLoader.font.setColor(Color.WHITE);

        HorseGame.gallopSoundID = AssetLoader.gallopSound
                .loop(HorseGame.gallopVol);
    }
}