Java Code Examples for com.badlogic.gdx.utils.Align#center()
The following examples show how to use
com.badlogic.gdx.utils.Align#center() .
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: MenuScreen.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
private int getAlign() { if (getStyle().align == null || "center".equals(getStyle().align)) return Align.center; if ("top".equals(getStyle().align)) return Align.top; if ("bottom".equals(getStyle().align)) return Align.bottom; if ("left".equals(getStyle().align)) return Align.left; if ("right".equals(getStyle().align)) return Align.right; return Align.center; }
Example 2
Source File: AlignUtils.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
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 3
Source File: AlignUtils.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
public static int getAlign(String s) { if ("bottom-right".equals(s)) return Align.bottomRight; else if ("bottom-left".equals(s)) return Align.bottomLeft; else if ("top-right".equals(s)) return Align.topRight; else if ("top-left".equals(s)) return Align.topLeft; else if ("right".equals(s)) return Align.right; else if ("left".equals(s)) return Align.left; else if ("bottom".equals(s)) return Align.bottom; else if ("top".equals(s)) return Align.top; else if ("center".equals(s)) return Align.center; return 0; }
Example 4
Source File: CCLabel.java From cocos-ui-libgdx with Apache License 2.0 | 5 votes |
@Override public Actor parse(CocoStudioUIEditor editor, ObjectData widget) { final TTFLabelStyle labelStyle = editor.createLabelStyle(widget, widget.getLabelText(), editor.getColor(widget.getCColor(), 0)); TTFLabel label = new TTFLabel(widget.getLabelText(), labelStyle); // 水平 int h = Integer.MAX_VALUE; if ("HT_Center".equals(widget.getHorizontalAlignmentType())) { h = Align.center; } else if ("HT_Left".equals(widget.getHorizontalAlignmentType())) { h = Align.left; } else if ("HT_Right".equals(widget.getHorizontalAlignmentType())) { h = Align.right; } // 垂直 int v = Integer.MAX_VALUE; if ("HT_Center".equals(widget.getVerticalAlignmentType())) { v = Align.center; } else if ("HT_Top".equals(widget.getVerticalAlignmentType())) { v = Align.top; } else if ("HT_Bottom".equals(widget.getVerticalAlignmentType())) { v = Align.bottom; } if (v != Integer.MAX_VALUE) { label.setAlignment(h, v); } return label; }
Example 5
Source File: TextRenderer.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
public static float getAlignDx(float width, int align) { if ((align & Align.left) != 0) return 0; else if ((align & Align.right) != 0) return -width; else if ((align & Align.center) != 0) return -width / 2.0f; return -width / 2.0f; }
Example 6
Source File: TextRenderer.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
public static float getAlignDy(float height, int align) { if ((align & Align.bottom) != 0) return 0; else if ((align & Align.top) != 0) return -height; else if ((align & Align.center) != 0) return -height / 2.0f; return 0; }
Example 7
Source File: AnimationRenderer.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
public static float getAlignDx(float width, int align) { if ((align & Align.left) != 0) return 0; else if ((align & Align.right) != 0) return -width; else if ((align & Align.center) != 0) return -width / 2.0f; return -width / 2.0f; }
Example 8
Source File: AnimationRenderer.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
public static float getAlignDy(float height, int align) { if ((align & Align.bottom) != 0) return 0; else if ((align & Align.top) != 0) return -height; else if ((align & Align.center) != 0) return -height / 2.0f; return 0; }
Example 9
Source File: SplashMenu.java From Cubes with MIT License | 5 votes |
public SplashMenu() { logo = new Image(new TextureRegionDrawable(Assets.getTextureRegion("core:logo.png")), Scaling.fillY, Align.center); text = new Label("Loading " + Branding.DEBUG, new Label.LabelStyle(Fonts.smallHUD, Color.WHITE)); stage.addActor(logo); stage.addActor(text); }
Example 10
Source File: TabbedPane.java From gdx-ai with Apache License 2.0 | 5 votes |
private void initialize () { setTouchable(Touchable.enabled); tabTitleTable = new Table(); tabBodyStack = new Stack(); selectedIndex = -1; // Create 1st row Cell<?> leftCell = add(new Image(style.titleBegin)); Cell<?> midCell = add(tabTitleTable); Cell<?> rightCell = add(new Image(style.titleEnd)); switch (tabTitleAlign) { case Align.left: leftCell.width(((Image)leftCell.getActor()).getWidth()).bottom(); midCell.left(); rightCell.expandX().fillX().bottom(); break; case Align.right: leftCell.expandX().fillX().bottom(); midCell.right(); rightCell.width(((Image)rightCell.getActor()).getWidth()).bottom(); break; case Align.center: leftCell.expandX().fillX().bottom(); midCell.center(); rightCell.expandX().fillX().bottom(); break; default: throw new IllegalArgumentException("TabbedPane align must be one of left, center, right"); } // Create 2nd row row(); Table t = new Table(); t.setBackground(style.bodyBackground); t.add(tabBodyStack); add(t).colspan(3).expand().fill(); }
Example 11
Source File: RenderSystem.java From riiablo with Apache License 2.0 | 4 votes |
private void drawDebugSpecial(ShapeRenderer shapes) { for (int i = Map.WALL_OFFSET, x, y; i < Map.WALL_OFFSET + Map.MAX_WALLS; i++) { int startX2 = startX; int startY2 = startY; float startPx2 = startPx; float startPy2 = startPy; for (y = 0; y < viewBuffer.length; y++) { int tx = startX2; int ty = startY2; int stx = tx * Tile.SUBTILE_SIZE; int sty = ty * Tile.SUBTILE_SIZE; float px = startPx2; float py = startPy2; int size = viewBuffer[y]; for (x = 0; x < size; x++) { Map.Zone zone = map.getZone(stx, sty); if (zone != null) { DS1.Cell cell = zone.getCell(i, tx, ty); if (cell != null) { if (Map.ID.POPPADS.contains(cell.id)) { shapes.setColor(Map.ID.getColor(cell)); Map.Preset preset = zone.getGrid(tx, ty); Map.Preset.PopPad popPad = preset.popPads.get(cell.id); if (popPad.startX == zone.getGridX(tx) && popPad.startY == zone.getGridY(ty)) { int width = popPad.endX - popPad.startX; int height = popPad.endY - popPad.startY; iso.getPixOffset(tmpVec2); float offsetX = tmpVec2.x; float offsetY = tmpVec2.y; iso.toScreen(tmpVec2.set(stx, sty)); float topLeftX = tmpVec2.x - offsetX; float topLeftY = tmpVec2.y - offsetY; iso.toScreen(tmpVec2.set(stx, sty).add(width, 0)); float topRightX = tmpVec2.x - offsetX; float topRightY = tmpVec2.y - offsetY; iso.toScreen(tmpVec2.set(stx, sty).add(0, height)); float bottomLeftX = tmpVec2.x - offsetX; float bottomLeftY = tmpVec2.y - offsetY; iso.toScreen(tmpVec2.set(stx, sty).add(width, height)); float bottomRightX = tmpVec2.x - offsetX; float bottomRightY = tmpVec2.y - offsetY; shapes.line(topLeftX, topLeftY, topRightX, topRightY); shapes.line(topRightX, topRightY, bottomRightX, bottomRightY); shapes.line(bottomRightX, bottomRightY, bottomLeftX, bottomLeftY); shapes.line(bottomLeftX, bottomLeftY, topLeftX, topLeftY); } } else { shapes.setColor(Color.WHITE); DebugUtils.drawDiamond2(shapes, px, py, Tile.WIDTH, Tile.HEIGHT); } shapes.end(); batch.begin(); batch.setShader(null); BitmapFont font = Riiablo.fonts.consolas12; String str = String.format("%s%n%08x", Map.ID.getName(cell.id), cell.value); GlyphLayout layout = new GlyphLayout(font, str, 0, str.length(), font.getColor(), 0, Align.center, false, null); font.draw(batch, layout, px + Tile.WIDTH50, py + Tile.HEIGHT50 + font.getLineHeight() / 4); batch.end(); batch.setShader(Riiablo.shader); shapes.begin(ShapeRenderer.ShapeType.Line); } } tx++; stx += Tile.SUBTILE_SIZE; px += Tile.WIDTH50; py -= Tile.HEIGHT50; } startY2++; if (y >= tilesX - 1) { startX2++; startPy2 -= Tile.HEIGHT; } else { startX2--; startPx2 -= Tile.WIDTH; } } } }
Example 12
Source File: Tooltip.java From vis-ui with Apache License 2.0 | 4 votes |
public Builder (String text) { this(text, Align.center); }
Example 13
Source File: TextRenderer.java From bladecoder-adventure-engine with Apache License 2.0 | 4 votes |
@Override public void draw(SpriteBatch batch, float x, float y, float scaleX, float scaleY, float rotation, Color tint) { float dx = getAlignDx(getWidth(), orgAlign); float dy = getAlignDy(getHeight(), orgAlign); if (font != null && text != null) { if (tint != null && !tint.equals(color)) { color.set(tint); String tt = text; if (tt.charAt(0) == I18N.PREFIX) tt = world.getI18N().getString(tt.substring(1)); if (editorTranslatedText != null) tt = editorTranslatedText; layout.setText(font, tt, color, 0, textAlign, false); } Matrix4 tm = batch.getTransformMatrix(); tmp.set(tm); float originX = dx; float originY = layout.height + dy; if (textAlign == Align.right) originX += getWidth(); else if (textAlign == Align.center) originX += getWidth() / 2; tm.translate(x, y, 0).rotate(0, 0, 1, rotation).scale(scaleX, scaleY, 1).translate(originX, originY, 0); batch.setTransformMatrix(tm); font.draw(batch, layout, 0, 0); batch.setTransformMatrix(tmp); } else { RectangleRenderer.draw(batch, x + dx * scaleX, y + dy * scaleY, getWidth() * scaleX, getHeight() * scaleY, Color.RED); } }