com.badlogic.gdx.utils.Align Java Examples

The following examples show how to use com.badlogic.gdx.utils.Align. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RadialBlurEffect.java    From gdx-vfx with Apache License 2.0 6 votes vote down vote up
/**
 * Specify the zoom origin in {@link Align} bits.
 * @see Align
 */
public void setOrigin(int align) {
    final float originX;
    final float originY;
    if ((align & Align.left) != 0) {
        originX = 0f;
    } else if ((align & Align.right) != 0) {
        originX = 1f;
    } else {
        originX = 0.5f;
    }
    if ((align & Align.bottom) != 0) {
        originY = 0f;
    } else if ((align & Align.top) != 0) {
        originY = 1f;
    } else {
        originY = 0.5f;
    }
    setOrigin(originX, originY);
}
 
Example #2
Source File: ZoomEffect.java    From gdx-vfx with Apache License 2.0 6 votes vote down vote up
/**
 * Specify the zoom origin in {@link Align} bits.
 * @see Align
 */
public void setOrigin(int align) {
    final float originX;
    final float originY;
    if ((align & Align.left) != 0) {
        originX = 0f;
    } else if ((align & Align.right) != 0) {
        originX = 1f;
    } else {
        originX = 0.5f;
    }
    if ((align & Align.bottom) != 0) {
        originY = 0f;
    } else if ((align & Align.top) != 0) {
        originY = 1f;
    } else {
        originY = 0.5f;
    }
    setOrigin(originX, originY);
}
 
Example #3
Source File: ParallelVsSequenceTest.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
protected void setRandomNonOverlappingPosition (SteeringActor character, Array<? extends SteeringActor> others,
	float minDistanceFromBoundary) {
	int maxTries = Math.max(100, others.size * others.size);
	SET_NEW_POS:
	while (--maxTries >= 0) {
		character.setPosition(MathUtils.random(stage.getWidth()), MathUtils.random(stage.getHeight()), Align.center);
		character.getPosition().set(character.getX(Align.center), character.getY(Align.center));
		for (int i = 0; i < others.size; i++) {
			SteeringActor other = (SteeringActor)others.get(i);
			if (character.getPosition().dst(other.getPosition()) <= character.getBoundingRadius() + other.getBoundingRadius()
				+ minDistanceFromBoundary) continue SET_NEW_POS;
		}
		return;
	}
	throw new GdxRuntimeException("Probable infinite loop detected");
}
 
Example #4
Source File: VectorFieldModuleWrapper.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
protected void configureSlots () {
    addInputSlot("field position", VectorFieldModule.POSITION);
    addInputSlot("field size", VectorFieldModule.SIZE_SCALE);
    addInputSlot("field force", VectorFieldModule.FORCE_SCALE);

    addOutputSlot("velocity", VectorFieldModule.VELOCITY);
    addOutputSlot("angle", VectorFieldModule.ANGLE);

    leftWrapper.add().expandY().row();
    rightWrapper.add().expandY().row();

    vectorFieldLabel = new Label("drop .fga file here", getSkin());
    vectorFieldLabel.setAlignment(Align.center);
    vectorFieldLabel.setWrap(true);
    contentWrapper.add(vectorFieldLabel).padTop(60f).padBottom(10f).size(180, 50).center().expand();
}
 
Example #5
Source File: HotkeyButton.java    From riiablo with Apache License 2.0 6 votes vote down vote up
public HotkeyButton(final DC dc, final int index, int skillId, Stat chargedSkill) {
  super(new ButtonStyle() {{
    up       = new TextureRegionDrawable(dc.getTexture(index));
    down     = new TextureRegionDrawable(dc.getTexture(index + 1));
    disabled = up;
    pressedOffsetX = pressedOffsetY = -2;
  }});

  this.skillId = skillId;
  this.chargedSkill = chargedSkill;
  add(hotkey = new Label("", Riiablo.fonts.font16, Riiablo.colors.gold)).align(Align.topRight);
  row();
  add().grow();
  row();
  add(charges = new Label(chargedSkill != null ? Integer.toString(chargedSkill.value1()) : "", Riiablo.fonts.font16, Riiablo.colors.blue)).align(Align.bottomLeft);
  pad(2);
  pack();

  setDisabledBlendMode(BlendMode.DARKEN, Riiablo.colors.darkenRed);
}
 
Example #6
Source File: MPQViewer.java    From riiablo with Apache License 2.0 6 votes vote down vote up
protected void drawDelegate(Batch batch, float a) {
  /*ShaderProgram s = null;
  if (shader != null && palette != null) {
    batch.flush();
    s = batch.getShader();
    batch.setShader(shader);

    palette.bind(1);
    Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
    shader.setUniformi("ColorTable", 1);
  }*/

  drawable.draw(batch,
      getX(Align.center) - (drawable.getMinWidth() / 2),
      getY(Align.center) - (drawable.getMinHeight() / 2),
      drawable.getMinWidth(), drawable.getMinHeight());

  /*if (shader != null && palette != null) {
    batch.setShader(s);
  }*/
}
 
Example #7
Source File: ChatGUI.java    From Radix with MIT License 6 votes vote down vote up
@Override
public void onChatMessage(Message message) {
    if (message instanceof TranslationMessage) {
        TranslationMessage tmsg = (TranslationMessage)message;
        try {
            chatMessages.add(String.format("<%s> %s", tmsg.getTranslationParams()[0], tmsg.getTranslationParams()[1]));
        } catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
            chatMessages.add(message.getFullText());
        }
    } else {
        chatMessages.add(message.getFullText());
    }

    StringBuilder messages = new StringBuilder();
    for(String s : chatMessages) {
        messages.append(s).append("\n");
    }
    fontCache.clear();
    chatAreaLayout = fontCache.addText(messages, 0, 0, 512, Align.left, true);
    fontCache.setPosition(4, chatAreaLayout.height + 50);
}
 
Example #8
Source File: Message.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public static void init(Skin skin) {
	msg = new Label("", skin, "message") {

		@Override
		public Actor hit(float x, float y, boolean touchable) {
			if (isModal)
				return this;

			return null;
		}
	};

	Message.skin = skin;
	msg.setWrap(true);
	msg.setAlignment(Align.center, Align.center);
}
 
Example #9
Source File: ShareScoreScreen.java    From Klooni1010 with GNU General Public License v3.0 6 votes vote down vote up
ShareScoreScreen(final Klooni game, final Screen lastScreen,
                 final int score, final boolean timeMode) {
    this.game = game;
    this.lastScreen = lastScreen;

    this.score = score;
    this.timeMode = timeMode;

    final Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.font = game.skin.getFont("font_small");

    infoLabel = new Label("Generating image...", labelStyle);
    infoLabel.setColor(Klooni.theme.textColor);
    infoLabel.setAlignment(Align.center);
    infoLabel.layout();
    infoLabel.setPosition(
            (Gdx.graphics.getWidth() - infoLabel.getWidth()) * 0.5f,
            (Gdx.graphics.getHeight() - infoLabel.getHeight()) * 0.5f);

    spriteBatch = new SpriteBatch();
}
 
Example #10
Source File: VisCheckBox.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
public VisCheckBox (String text, VisCheckBoxStyle style) {
	super(text, style);
	clearChildren();

	bgImage = new Image(style.checkBackground);
	tickImage = new Image(style.tick);
	imageStackCell = add(imageStack = new Stack(bgImage, tickImage));
	Label label = getLabel();
	add(label).padLeft(5);
	label.setAlignment(Align.left);
	setSize(getPrefWidth(), getPrefHeight());

	addListener(new InputListener() {
		@Override
		public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
			if (isDisabled() == false) FocusManager.switchFocus(getStage(), VisCheckBox.this);
			return false;
		}
	});
}
 
Example #11
Source File: Hud.java    From Unlucky with MIT License 6 votes vote down vote up
/**
 * Creates the level descriptor window
 */
private void createLevelDescriptor() {
    levelDescriptor = new Window("", rm.skin);
    levelDescriptor.getTitleLabel().setFontScale(0.5f);
    levelDescriptor.getTitleLabel().setAlignment(Align.center);
    levelDescriptor.setMovable(false);
    levelDescriptor.setTouchable(Touchable.disabled);
    levelDescriptor.setKeepWithinStage(false);
    levelDescriptor.setVisible(false);
    levelDesc = new Label("", new Label.LabelStyle(rm.pixel10, Color.WHITE));
    levelDesc.setFontScale(0.5f);
    levelDesc.setAlignment(Align.center);
    levelDescriptor.left();
    levelDescriptor.padTop(12);
    levelDescriptor.padLeft(2);
    levelDescriptor.padBottom(4);
    levelDescriptor.add(levelDesc).width(70);
    stage.addActor(levelDescriptor);
    levelMoving = new Moving(new Vector2(), new Vector2(), 150.f);
}
 
Example #12
Source File: PageGroup.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
private void spotlightRegion(RegionModel region) {
    if (this.region == region) return;

    this.region = region;
    active = true;

    // You can customize what is shown when a user hovers on region in here.
    final TextureAtlasData.Region regionData = region.getRegionData();
    final StringBuilder sb = new StringBuilder();
    sb.append(regionData.name);
    if (regionData.index >= 0) {
        sb.append("[#fbf236ff] idx:" + regionData.index);
    }

    font.getData().setScale(1f);
    glText.setText(font, sb.toString(), Color.WHITE, 0f, Align.left, false);
}
 
Example #13
Source File: GameOverOverlay.java    From ud406 with MIT License 6 votes vote down vote up
public void render(SpriteBatch batch) {

        viewport.apply();
        batch.setProjectionMatrix(viewport.getCamera().combined);
        batch.begin();

        // TODO: Draw a game over message
        // Feel free to get more creative with this screen. Perhaps you could cover the screen in enemy robots?

        float timeElapsed = Utils.secondsSince(startTime);
        int enemiesToShow = (int) (Constants.ENEMY_COUNT * (timeElapsed / Constants.LEVEL_END_DURATION));

        for (int i = 0; i < enemiesToShow; i++){
            Enemy enemy = enemies.get(i);
            enemy.update(0);
            enemy.render(batch);
        }

        font.draw(batch, Constants.GAME_OVER_MESSAGE, viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 2.5f, 0, Align.center, false);

        batch.end();

    }
 
Example #14
Source File: ItemTooltip.java    From Unlucky with MIT License 6 votes vote down vote up
public ItemTooltip(Skin skin) {
    super("", skin);
    desc = new Label("", skin);
    desc.setFontScale(0.5f);
    this.getTitleLabel().setFontScale(0.5f);

    common = new Label.LabelStyle(skin.getFont("default-font"), new Color(1, 1, 1, 1));
    rare = new Label.LabelStyle(skin.getFont("default-font"), new Color(0, 200 / 255.f, 0, 1));
    epic = new Label.LabelStyle(skin.getFont("default-font"), new Color(0, 180 / 255.f, 1, 1));
    legendary = new Label.LabelStyle(skin.getFont("default-font"), new Color(164 / 255.f, 80 / 255.f, 1, 1));

    left();
    // fix padding because of scaling
    this.padTop(12);
    this.padLeft(2);
    this.padBottom(4);
    add(desc);
    pack();
    this.setTouchable(Touchable.disabled);
    this.setVisible(false);
    this.setMovable(false);
    this.setOrigin(Align.bottomLeft);
}
 
Example #15
Source File: SingleplayerSaveDeleteMenu.java    From Cubes with MIT License 6 votes vote down vote up
public SingleplayerSaveDeleteMenu(final Save save) {
  title = new Label(Localization.get("menu.singleplayer.delete.title"), skin.get("title", Label.LabelStyle.class));
  text = new Label(Localization.get("menu.singleplayer.delete.text", save.name), skin);
  delete = new TextButton(Localization.get("menu.singleplayer.delete.delete", save.name), skin);
  back = MenuTools.getBackButton(this);

  text.setAlignment(Align.center);

  delete.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      ClientSaveManager.deleteSave(save);
      Menu prev = MenuManager.getPrevious(SingleplayerSaveDeleteMenu.this);
      if (!(prev instanceof SingleplayerSavesMenu)) return;
      ((SingleplayerSavesMenu) prev).updateSavesList();
      Adapter.setMenu(prev);
    }
  });

  stage.addActor(title);
  stage.addActor(text);
  stage.addActor(delete);
  stage.addActor(back);
}
 
Example #16
Source File: DieMessageWindow.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
@Override protected void initialize() {
    Table table = new Table(Config.skin);
    table.setBackground(Config.skin.getDrawable("ui-tutorial-window-background"));
    label = new LocLabel("", ACTIVE);
    label.setWrap(true);
    label.setAlignment(Align.center);

    table.setTouchable(Touchable.disabled);

    Label tapToContinue = new LocLabel("tap-to-continue", INACTIVE);
    tapToContinue.setWrap(true);
    tapToContinue.setAlignment(Align.center);

    table.add(imageTable).padTop(6).row();
    table.add(label).width(100).row();
    table.add(new Image(Config.skin, "ui-tutorial-window-line")).padTop(4).row();
    table.add(tapToContinue).width(80).row();

    this.table.add(table);
}
 
Example #17
Source File: Scene2dSteeringTest.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
protected void setRandomNonOverlappingPosition (SteeringActor character, Array<SteeringActor> others,
	float minDistanceFromBoundary) {
	int maxTries = Math.max(100, others.size * others.size); 
	SET_NEW_POS:
	while (--maxTries >= 0) {
		character.setPosition(MathUtils.random(container.stageWidth), MathUtils.random(container.stageHeight), Align.center);
		character.getPosition().set(character.getX(Align.center), character.getY(Align.center));
		for (int i = 0; i < others.size; i++) {
			SteeringActor other = (SteeringActor)others.get(i);
			if (character.getPosition().dst(other.getPosition()) <= character.getBoundingRadius() + other.getBoundingRadius()
				+ minDistanceFromBoundary) continue SET_NEW_POS;
		}
		return;
	}
	throw new GdxRuntimeException("Probable infinite loop detected");
}
 
Example #18
Source File: AnimationDrawer.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public void setActor(BaseActor a) {
	if (renderer != null) {
		renderer.dispose();
		renderer = null;
	}

	if (a instanceof SpriteActor && ((SpriteActor) a).getRenderer() instanceof AnimationRenderer) {
		ActorRenderer r = ((SpriteActor) a).getRenderer();

		if (r instanceof Sprite3DRenderer) {
			renderer = new Sprite3DRenderer();
			((Sprite3DRenderer) renderer).setSpriteSize(new Vector2(r
					.getWidth(), r.getHeight()));
		} else if (r instanceof SpineRenderer) {
			renderer = new SpineRenderer();
			((SpineRenderer)renderer).enableEvents(false);
			((SpineRenderer)renderer).setSkin(((SpineRenderer) r).getSkin());
		} else if (r instanceof ImageRenderer) {
			renderer = new ImageRenderer();				
		} else if (r instanceof AtlasRenderer) {
			renderer = new AtlasRenderer();
		}
		
		renderer.setOrgAlign(Align.bottom);
	}
}
 
Example #19
Source File: DialogWelcome.java    From skin-composer with MIT License 6 votes vote down vote up
@Override
public Dialog show(Stage stage) {
    Dialog dialog = super.show(stage);
    
    if (getWidth() > Gdx.graphics.getWidth()) {
        setWidth(Gdx.graphics.getWidth());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }
    
    if (getHeight() > Gdx.graphics.getHeight()) {
        setHeight(Gdx.graphics.getHeight());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }
    
    resetWidth = getWidth();
    resetHeight = getHeight();
    main.getStage().setScrollFocus(scrollPane);
    fire(new DialogEvent(DialogEvent.Type.OPEN));
    return dialog;
}
 
Example #20
Source File: DialogWelcome.java    From skin-composer with MIT License 6 votes vote down vote up
@Override
public Dialog show(Stage stage, Action action) {
    Dialog dialog = super.show(stage, action);
    
    if (getWidth() > Gdx.graphics.getWidth()) {
        setWidth(Gdx.graphics.getWidth());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }
    
    if (getHeight() > Gdx.graphics.getHeight()) {
        setHeight(Gdx.graphics.getHeight());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }
    
    resetWidth = getWidth();
    resetHeight = getHeight();
    main.getStage().setScrollFocus(scrollPane);
    fire(new DialogEvent(DialogEvent.Type.OPEN));
    return dialog;
}
 
Example #21
Source File: AlignUtils.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public static String getAlign(int align) {
	switch (align) {
	case Align.bottomRight:
		return "bottom-right";
	case Align.bottomLeft:
		return "bottom-left";
	case Align.topRight:
		return "top-right";
	case Align.topLeft:
		return "top-left";
	case Align.right:
		return "right";
	case Align.left:
		return "left";
	case Align.bottom:
		return "bottom";
	case Align.top:
		return "top";
	case Align.center:
		return "center";
	}

	return "";
}
 
Example #22
Source File: DialogWarnings.java    From skin-composer with MIT License 6 votes vote down vote up
@Override
public Dialog show(Stage stage) {
    Dialog dialog = super.show(stage);
    if (getWidth() > Gdx.graphics.getWidth()) {
        setWidth(Gdx.graphics.getWidth());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }
    
    if (getHeight() > Gdx.graphics.getHeight()) {
        setHeight(Gdx.graphics.getHeight());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }
    
    resetWidth = getWidth();
    resetHeight = getHeight();
    main.getStage().setScrollFocus(scrollPane);
    return dialog;
}
 
Example #23
Source File: DialogWarnings.java    From skin-composer with MIT License 6 votes vote down vote up
@Override
public Dialog show(Stage stage, Action action) {
    Dialog dialog = super.show(stage, action);
    
    if (getWidth() > Gdx.graphics.getWidth()) {
        setWidth(Gdx.graphics.getWidth());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }
    
    if (getHeight() > Gdx.graphics.getHeight()) {
        setHeight(Gdx.graphics.getHeight());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }
    
    resetWidth = getWidth();
    resetHeight = getHeight();
    main.getStage().setScrollFocus(scrollPane);
    return dialog;
}
 
Example #24
Source File: DialogFactory.java    From skin-composer with MIT License 6 votes vote down vote up
public void showDeleteStyleDialog(Skin skin, Stage stage) {
    StyleData styleData = main.getRootTable().getSelectedStyle();

    Dialog dialog = new Dialog("Delete Style", skin, "bg") {
        @Override
        protected void result(Object object) {
            if ((Boolean) object) {
                main.getUndoableManager().addUndoable(new DeleteStyleUndoable(styleData, main), true);
            }
        }
    };
    dialog.getTitleLabel().setAlignment(Align.center);
    dialog.getContentTable().defaults().padLeft(10.0f).padRight(10.0f);
    dialog.text("Are you sure you want to delete style " + styleData.name + "?");
    dialog.getContentTable().getCells().first().pad(10.0f);

    dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
    dialog.button("Yes, delete the style", true).button("No", false);
    dialog.getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());

    dialog.key(Input.Keys.ENTER, true).key(Input.Keys.ESCAPE, false);

    dialog.show(stage);
}
 
Example #25
Source File: DropVisualizer.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
@Override public IFuture<Void> visualize(DroppedItem drop) {
    final Future<Void> future = new Future<Void>();

    Group group = new Group();
    Tile image = new Tile("item/" + drop.item.name);
    Label counter = new Label(String.valueOf(drop.count), Config.skin);
    counter.setSize(image.getWidth(), image.getHeight());
    counter.setAlignment(Align.right | Align.bottom);
    group.addActor(image);
    group.addActor(counter);
    group.setTransform(false);
    visualizer.viewController.notificationLayer.addActor(group);
    group.setPosition(drop.target.getX() * ViewController.CELL_SIZE, drop.target.getY() * ViewController.CELL_SIZE);
    group.addAction(Actions.parallel(
        Actions.moveBy(0, 30, 1f, Interpolation.fade),
        Actions.alpha(0, 1f, Interpolation.fade),
        Actions.delay(0.4f, Actions.run(new Runnable() {
            @Override public void run() {
                future.happen();
            }
        }))
    ));
    return future;
}
 
Example #26
Source File: LabelWidget.java    From talos with Apache License 2.0 5 votes vote down vote up
@Override
public Actor getSubWidget() {
	propertyValue = new Label("", TalosMain.Instance().getSkin());
	propertyValue.setWidth(170);
	propertyValue.setEllipsis(true);
	propertyValue.setAlignment(Align.right);

	return propertyValue;
}
 
Example #27
Source File: DieStore.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public DieStore(Die die, UserData userData, Callback callback) {
    this.die = die;
    this.userData = userData;
    this.callback = callback;
    this.shopComparator = Ability.shopComparator(die);
    table.setTouchable(Touchable.enabled);
    table.align(Align.top | Align.left);
    addActor(table);
    refresh();
    setSize(getPrefWidth(), getPrefHeight());
}
 
Example #28
Source File: PropertyWidget.java    From talos with Apache License 2.0 5 votes vote down vote up
protected void build(String name) {
	if(name != null) {
		propertyName = new Label(name + ":", TalosMain.Instance().getSkin());
		add(propertyName).left();
		propertyName.setAlignment(Align.left);
		valueContainer = new Table();
		add(valueContainer).right().expandX().minWidth(170);
		addToContainer(getSubWidget());
	} else {
		add(getSubWidget()).growX();
	}
}
 
Example #29
Source File: MonospaceFontGlyphLayoutTest.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
@Test
public void testLayoutRightAlignLineBreak() {
	final String str = "abc\ndef";

	glyphLayout.setText(str, color, -1f, Align.right, true);

	final float lineWidth = (3 * FONT_CHARACTER_WIDTH) + (FONT_SPACING * 3);
	float expectedX = 0f;
	float expectedY = 0f;
	for(int i = 0; i < str.length(); i++) {
		if(str.charAt(i) == '\n') {
			expectedX = 0f;
			expectedY += FONT_LINE_HEIGHT;
			continue;
		}

		Assert.assertEquals(expectedX, glyphLayout.getGlyphs().get(i).x, 0.01f);
		Assert.assertEquals(expectedY, glyphLayout.getGlyphs().get(i).y, 0.01f);
		Assert.assertEquals(str.charAt(i), glyphLayout.getGlyphs().get(i).glyphChar);

		expectedX += FONT_CHARACTER_WIDTH + FONT_SPACING;
		if(str.charAt(i) == '\n') {
			expectedX = 0f;
			expectedY += FONT_LINE_HEIGHT;
		}
	}

	Assert.assertEquals((FONT_CHARACTER_WIDTH * 3f) + (FONT_SPACING * 2f), glyphLayout.getWidth(), 0.01f);
	Assert.assertEquals(FONT_LINE_HEIGHT * 2f, glyphLayout.getHeight(), 0.01f);
}
 
Example #30
Source File: BottomMenu.java    From Norii with Apache License 2.0 5 votes vote down vote up
private void populateStatsGroup() {
	final float statsWidth = STATS_MENU_WIDTH_TILES * tileWidthPixel;
	final float statsHeight = BOTTOM_MENU_HEIGHT_TILES;

	statsGroup.setHeight(statsHeight);
	statsGroup.setWidth(statsWidth);
	statsGroup.align(Align.left);

	addLabelsToStatsGroup();

	statsGroupContainer = new Container<Table>(statsGroup);
	bottomMenuTable.addActor(statsGroupContainer.prefSize(statsWidth, statsHeight));
	statsGroup.setFillParent(true);
}