Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Table#setPosition()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Table#setPosition() . 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: ToastManager.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
private void updateToastsPositions () {
	boolean bottom = (alignment & Align.bottom) != 0;
	boolean left = (alignment & Align.left) != 0;
	float y = bottom ? screenPadding : root.getHeight() - screenPadding;

	for (Toast toast : toasts) {
		Table table = toast.getMainTable();
		table.setPosition(
				left ? screenPadding : root.getWidth() - table.getWidth() - screenPadding,
				bottom ? y : y - table.getHeight());

		y += (table.getHeight() + messagePadding) * (bottom ? 1 : -1);
	}
}
 
Example 2
Source File: ToastManager.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
private void updateToastsPositions () {
	boolean bottom = (alignment & Align.bottom) != 0;
	boolean left = (alignment & Align.left) != 0;
	float y = bottom ? screenPaddingY : root.getHeight() - screenPaddingY;

	for (Toast toast : toasts) {
		Table table = toast.getMainTable();
		table.setPosition(
				left ? screenPaddingX : root.getWidth() - table.getWidth() - screenPaddingX,
				bottom ? y : y - table.getHeight());

		y += (table.getHeight() + messagePadding) * (bottom ? 1 : -1);
	}
}
 
Example 3
Source File: ScreenMenu.java    From RuinsOfRevenge with MIT License 5 votes vote down vote up
public ScreenMenu(final ResourceLoader resources, final RuinsOfRevenge game) {
	super(new Stage(), game);
	this.resources = resources;
	this.game = game;
	this.background = resources.getRegion("background");
	background.getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
	this.ruinsOfRevengeText = resources.getRegion("RuinsOfRevenge");

	skin = resources.getSkin("uiskin");

	Image rorLogo = new Image(ruinsOfRevengeText);
	TextButton play = new TextButton("Play", skin);
	TextButton settings = new TextButton("Settings", skin);
	TextButton exit = new TextButton("Exit", skin);

	play.addListener(playListener);
	settings.addListener(settingsListener);
	exit.addListener(exitListener);

	table = new Table(skin);
	table.add(rorLogo).size(600, 200).space(32);
	table.row();
	table.add(play).size(320, 64).space(8);
	table.row();
	table.add(settings).size(320, 64).space(8);
	table.row();
	table.add(exit).size(320, 64).space(8);
	table.setPosition(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
	stage.addActor(table);
}
 
Example 4
Source File: ScreenPause.java    From RuinsOfRevenge with MIT License 5 votes vote down vote up
public ScreenPause(final ResourceLoader resources, final RuinsOfRevenge game) {
	super(new Stage(), game);
	this.resources = resources;
	this.game = game;

	skin = resources.getSkin("uiskin");

	TextButton play = new TextButton("Continue Playing", skin);
	TextButton settings = new TextButton("Settings", skin);
	TextButton backToMM = new TextButton("Back to Main Menu", skin);

	play.addListener(continueListener);
	settings.addListener(settingsListener);
	backToMM.addListener(backToMMListener);

	table = new Table(skin);
	table.add(play).size(320, 64).space(8);
	table.row();
	table.add(settings).size(320, 64).space(8);
	table.row();
	table.add(backToMM).size(320, 64).space(8);
	table.setPosition(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
	stage.addActor(table);
	stage.addListener(new KeyUpListener() {
		@Override
		public boolean keyUp(InputEvent event, int keycode) {
			if (keycode == Config.get().key("escape"))
				game.popScreen();
			return false;
		}
	});
}
 
Example 5
Source File: WidgetParser.java    From cocos-ui-libgdx with Apache License 2.0 4 votes vote down vote up
/**
 * 解析子控件
 */
public Group widgetChildrenParse(CocoStudioUIEditor editor,
                                 ObjectData widget, Group parent, Actor actor) {
    Table table = new Table();
    table.setClip(widget.isClipAble());
    table.setName(actor.getName());

    Scale scale = widget.getScale();

    if (scale != null) {
        table.setScale(scale.getScaleX(), scale.getScaleY());
    }

    table.setRotation(actor.getRotation());
    table.setVisible(actor.isVisible());

    table.setTouchable(widget.isTouchEnable() ? Touchable.enabled
        : Touchable.childrenOnly);

    // editor.getActors().get(actor.getName()).removeValue(actor, true);
    //
    // addActor(editor, table, option);

    actor.setVisible(true);
    actor.setTouchable(Touchable.disabled);

    if (scale != null || widget.getRotation() != 0) {
        table.setTransform(true);
    }

    table.setSize(actor.getWidth(), actor.getHeight());
    table.setPosition(actor.getX(), actor.getY());

    // 锚点就是子控件的锚点

    Scale anchorPoint = widget.getAnchorPoint();
    if (anchorPoint != null) {

        table.setOrigin(anchorPoint.getScaleX() * table.getWidth(),
            anchorPoint.getScaleY() * table.getHeight());
    }
    for (ObjectData childrenWidget : widget.getChildren()) {
        Actor childrenActor = editor.parseWidget(table, childrenWidget);
        if (childrenActor == null) {
            continue;
        }
        table.addActor(childrenActor);
    }
    sort(widget, table);

    // Widget的位置应该与Table重合.相当于Widget的属性被移植到了Table
    actor.setPosition(0, 0);
    actor.setScale(1, 1);
    table.addActorAt(0, actor);
    return table;
}
 
Example 6
Source File: MultiplayerScreen.java    From riiablo with Apache License 2.0 4 votes vote down vote up
public MultiplayerScreen(Animation D2logoLeft, Animation D2logoRight) {
  this.D2logoLeft = D2logoLeft;
  this.D2logoRight = D2logoRight;
  load();

  stage = new Stage(Riiablo.defaultViewport, Riiablo.batch);

  Riiablo.assets.finishLoadingAsset(TitleScreenDescriptor);
  TitleScreen = Riiablo.assets.get(TitleScreenDescriptor).getTexture();

  if (D2logoLeft == null || D2logoRight == null) {
    Riiablo.music.enqueue("data/global/music/Act1/tristram.wav");
  }

  if (D2logoLeft == null) {
    Riiablo.assets.finishLoadingAsset(D2logoBlackLeftDescriptor);
    Riiablo.assets.finishLoadingAsset(D2logoFireLeftDescriptor);
    this.D2logoLeft = D2logoLeft = Animation.builder()
        .layer(Riiablo.assets.get(D2logoBlackLeftDescriptor))
        .layer(Riiablo.assets.get(D2logoFireLeftDescriptor), BlendMode.LUMINOSITY)
        .build();
  }

  if (D2logoRight == null) {
    Riiablo.assets.finishLoadingAsset(D2logoBlackRightDescriptor);
    Riiablo.assets.finishLoadingAsset(D2logoFireRightDescriptor);
    this.D2logoRight = D2logoRight = Animation.builder()
        .layer(Riiablo.assets.get(D2logoBlackRightDescriptor))
        .layer(Riiablo.assets.get(D2logoFireRightDescriptor), BlendMode.LUMINOSITY)
        .build();
  }
  D2logo = new AnimationWrapper(D2logoLeft, D2logoRight);
  D2logo.setPosition(stage.getWidth() * 0.50f, stage.getHeight() * 0.75f);
  stage.addActor(D2logo);

  TextButton.TextButtonStyle style = new TextButton.TextButtonStyle() {{
      Riiablo.assets.finishLoadingAsset(WideButtonBlankDescriptor);
      DC6 WideButtonBlank = Riiablo.assets.get(WideButtonBlankDescriptor);
      up   = new TextureRegionDrawable(WideButtonBlank.getTexture(0));
      down = new TextureRegionDrawable(WideButtonBlank.getTexture(1));
      font = Riiablo.fonts.fontexocet10;
  }};
  ClickListener clickListener = new ClickListener() {
    @Override
    public void clicked(InputEvent event, float x, float y) {
      Actor actor = event.getListenerActor();
      if (actor == btnOpenBattlenet) {
        Riiablo.client.pushScreen(new LoginScreen(MultiplayerScreen.this.D2logoLeft, MultiplayerScreen.this.D2logoRight));
      } else if (actor == btnTCPIP) {
        Riiablo.client.pushScreen(new TCPIPScreen(MultiplayerScreen.this.D2logoLeft, MultiplayerScreen.this.D2logoRight));
      } else if (actor == btnCancel) {
        Riiablo.client.popScreen();
      }
    }
  };
  btnOpenBattlenet = new TextButton(5115, style);
  btnOpenBattlenet.addListener(clickListener);
  btnTCPIP = new TextButton(5116, style);
  btnTCPIP.addListener(clickListener);
  btnCancel = new TextButton(5134, style);
  btnCancel.addListener(clickListener);

  final Table panel = new Table() {{
    final float SPACING = 8;
    add(btnOpenBattlenet).space(SPACING).row();
    add(btnTCPIP).space(SPACING).row();
    add(btnCancel).space(SPACING).row();
    pack();
  }};
  panel.setPosition(stage.getWidth() / 2, D2logo.getY() / 2, Align.center);
  stage.addActor(panel);
}