com.badlogic.gdx.scenes.scene2d.ui.Table.pack()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(267)

本文整理了Java中com.badlogic.gdx.scenes.scene2d.ui.Table.pack()方法的一些代码示例,展示了Table.pack()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.pack()方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.ui.Table
类名称:Table
方法名:pack

Table.pack介绍

暂无

代码示例

代码示例来源:origin: libgdx/libgdx

  1. @Override
  2. public void create () {
  3. batch = new SpriteBatch();
  4. skin = new Skin(Gdx.files.internal("data/uiskin.json"));
  5. stage = new Stage();
  6. Gdx.input.setInputProcessor(stage);
  7. Table table = new Table();
  8. stage.addActor(table);
  9. table.setPosition(200, 65);
  10. Label label1 = new Label("This text is scaled 2x.", skin);
  11. label1.setFontScale(2);
  12. Label label2 = new Label(
  13. "This text is scaled. This text is scaled. This text is scaled. This text is scaled. This text is scaled. ", skin);
  14. label2.setWrap(true);
  15. label2.setFontScale(0.75f, 0.75f);
  16. table.debug();
  17. table.add(label1);
  18. table.row();
  19. table.add(label2).fill();
  20. table.pack();
  21. }

代码示例来源:origin: libgdx/libgdx

  1. table.pack();
  2. stage.addActor(table);
  3. table.pack();
  4. stage.addActor(table);

代码示例来源:origin: libgdx/libgdx

  1. table.add(label);
  2. table.add(new TextButton("Text Button", skin));
  3. table.pack();

代码示例来源:origin: libgdx/libgdx

  1. Table table = new Table().debug();
  2. table.add(g);
  3. table.pack();
  4. table.setPosition(5, 100);
  5. stage.addActor(table);
  6. table = new Table().debug();
  7. table.add(h);
  8. table.pack();
  9. table.setPosition(130, 100);
  10. stage.addActor(table);

代码示例来源:origin: kotcrab/vis-ui

  1. private <T extends Table> T prepareBuiltTable (final T table) {
  2. table.pack();
  3. return table;
  4. }

代码示例来源:origin: narfman0/GDXWorld

  1. @Override public void clicked(InputEvent event, float x, float y) {
  2. contents.removeActor(parentTable);
  3. tables.remove(table);
  4. contents.pack();
  5. }
  6. });

代码示例来源:origin: langurmonkey/gaiasky

  1. public void initialize(IStarFocus st) {
  2. this.st = st;
  3. table.clear();
  4. requestData(new GaiaDataListener(st));
  5. table.pack();
  6. //scroll.setWidth(Math.max(table.getWidth() + scroll.getStyle().vScroll.getMinWidth(), 500 * GlobalConf.SCALE_FACTOR));
  7. pack();
  8. me.setPosition(Math.round(stage.getWidth() / 2f - me.getWidth() / 2f), Math.round(stage.getHeight() / 2f - me.getHeight() / 2f));
  9. }

代码示例来源:origin: langurmonkey/gaiasky

  1. private void finish() {
  2. table.pack();
  3. scroll.setWidth(table.getWidth() + scroll.getStyle().vScroll.getMinWidth());
  4. pack();
  5. me.setPosition(Math.round(stage.getWidth() / 2f - me.getWidth() / 2f), Math.round(stage.getHeight() / 2f - me.getHeight() / 2f));
  6. }

代码示例来源:origin: langurmonkey/gaiasky

  1. public void ko(String error) {
  2. // Error
  3. Gdx.app.postRunnable(() -> {
  4. String msg = error;
  5. table.add(new OwnLabel(msg, skin, "ui-15"));
  6. table.pack();
  7. scroll.setHeight(table.getHeight() + pad);
  8. finish();
  9. });
  10. }

代码示例来源:origin: langurmonkey/gaiasky

  1. public void ko() {
  2. // Error getting data
  3. Gdx.app.postRunnable(() -> {
  4. String msg = I18n.bundle.format("error.gaiacatalog.data", st.getName());
  5. table.add(new OwnLabel(msg, skin, "ui-15"));
  6. table.pack();
  7. scroll.setHeight((float) Math.min(table.getHeight(), Gdx.graphics.getHeight() * 0.6) + pad);
  8. finish();
  9. });
  10. }

代码示例来源:origin: langurmonkey/gaiasky

  1. public void notFound() {
  2. // Not found
  3. String msg = I18n.bundle.format("error.gaiacatalog.notfound", st.getName());
  4. table.add(new OwnLabel(msg, skin, "ui-15"));
  5. table.pack();
  6. scroll.setHeight(table.getHeight() + pad);
  7. finish();
  8. }

代码示例来源:origin: langurmonkey/gaiasky

  1. public void recalculateSize() {
  2. // Save position
  3. float topy = getY() + getHeight();
  4. // Calculate new size
  5. guiLayout.pack();
  6. if (windowScroll != null) {
  7. windowScroll.setHeight(Math.min(guiLayout.getHeight() + 30, Gdx.graphics.getHeight() - 120));
  8. windowScroll.pack();
  9. mainVertical.setHeight(windowScroll.getHeight() + 30);
  10. mainVertical.pack();
  11. setHeight(windowScroll.getHeight() + 40);
  12. }
  13. pack();
  14. validate();
  15. // Restore position
  16. setY(topy - getHeight());
  17. }

代码示例来源:origin: kotcrab/vis-ui

  1. /** Displays toast. Toast will be displayed for given amount of seconds. */
  2. public void show (final Toast toast, float timeSec) {
  3. Table toastMainTable = toast.getMainTable();
  4. if (toastMainTable.getStage() != null) {
  5. remove(toast);
  6. }
  7. toasts.add(toast);
  8. toast.setToastManager(this);
  9. toast.fadeIn();
  10. toastMainTable.pack();
  11. root.addActor(toastMainTable);
  12. updateToastsPositions();
  13. if (timeSec > 0) {
  14. Timer.Task fadeOutTask = new Timer.Task() {
  15. @Override
  16. public void run () {
  17. toast.fadeOut();
  18. timersTasks.remove(toast);
  19. }
  20. };
  21. timersTasks.put(toast, fadeOutTask);
  22. Timer.schedule(fadeOutTask, timeSec);
  23. }
  24. }

代码示例来源:origin: crashinvaders/gdx-texture-packer-gui

  1. /** Displays toast. Toast will be displayed for given amount of seconds. */
  2. public Toast show (final Toast toast, float timeSec) {
  3. Table toastMainTable = toast.getMainTable();
  4. if (toastMainTable.getStage() != null) {
  5. remove(toast);
  6. }
  7. toasts.add(toast);
  8. toast.setToastManager(this);
  9. toast.fadeIn();
  10. toastMainTable.pack();
  11. root.addActor(toastMainTable);
  12. updateToastsPositions();
  13. if (timeSec > 0) {
  14. Timer.Task fadeOutTask = new Timer.Task() {
  15. @Override
  16. public void run () {
  17. toast.fadeOut();
  18. timersTasks.remove(toast);
  19. }
  20. };
  21. timersTasks.put(toast, fadeOutTask);
  22. Timer.schedule(fadeOutTask, timeSec);
  23. }
  24. return toast;
  25. }

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

  1. panel.pack();
  2. setWidth(getStage().getViewport().getScreenWidth());
  3. setHeight(Math.min(panel.getHeight(), getStage().getViewport().getScreenHeight() / 2));

代码示例来源:origin: manuelbua/uracer-kotd

  1. @Override
  2. protected void drawBackground (Batch batch, float parentAlpha, float x, float y) {
  3. float width = getWidth(), height = getHeight();
  4. float padTop = getPadTop();
  5. super.drawBackground(batch, parentAlpha, x, y);
  6. // Draw button table.
  7. buttonTable.getColor().a = getColor().a;
  8. buttonTable.pack();
  9. buttonTable.setPosition(width - buttonTable.getWidth(), Math.min(height - padTop, height - buttonTable.getHeight()));
  10. buttonTable.draw(batch, parentAlpha);
  11. // Draw the title without the batch transformed or clipping applied.
  12. y += height;
  13. TextBounds bounds = titleCache.getBounds();
  14. if ((titleAlignment & Align.left) != 0)
  15. x += getPadLeft();
  16. else if ((titleAlignment & Align.right) != 0)
  17. x += width - bounds.width - getPadRight();
  18. else
  19. x += (width - bounds.width) / 2;
  20. if ((titleAlignment & Align.top) == 0) {
  21. if ((titleAlignment & Align.bottom) != 0)
  22. y -= padTop - bounds.height;
  23. else
  24. y -= (padTop - bounds.height) / 2;
  25. }
  26. titleCache.setColors(tmpColor.set(getColor()).mul(style.titleFontColor));
  27. titleCache.setPosition((int)x, (int)y - 15); // HACK for Kenney's skin only!!
  28. titleCache.draw(batch, parentAlpha);
  29. }

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

  1. table.pack();
  2. setActor(table);

代码示例来源:origin: dsaltares/libgdx-cookbook

  1. table.pack();

代码示例来源:origin: dsaltares/libgdx-cookbook

  1. table.pack();

代码示例来源:origin: rafaskb/typing-label

  1. table.add(buttonPause, buttonResume, buttonRestart, buttonSkip);
  2. table.pack();
  3. Table.debugCellColor.set(Color.DARK_GRAY);

相关文章