当前位置: 首页>>代码示例>>Java>>正文


Java Button.addListener方法代码示例

本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.Button.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java Button.addListener方法的具体用法?Java Button.addListener怎么用?Java Button.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.scenes.scene2d.ui.Button的用法示例。


在下文中一共展示了Button.addListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initHUD

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
/**
 * Function used to initialize all the elements of the HUD and add the respective Listeners.
 */
private void initHUD() {
    Table hudTable = new Table();
    hudTable.setFillParent(true);

    Button pauseButton = new Button(new TextureRegionDrawable(
            new TextureRegion(game.getAssetManager().get("pause.png", Texture.class))));

    scoreText = new Label("0:00", skin);
    scoreText.setFontScale(FONT_SCALE, FONT_SCALE);

    pauseButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            model.togglePause();
        }
    });

    hudTable.top();
    hudTable.add(scoreText).size(HUD_ELEMENTS_SIZE, HUD_ELEMENTS_SIZE).expandX()
            .left().fill().padLeft(HORIZONTAL_PAD).padTop(VERTICAL_PAD);
    hudTable.add(pauseButton).size(HUD_ELEMENTS_SIZE, HUD_ELEMENTS_SIZE).fill()
            .padRight(HORIZONTAL_PAD).padTop(VERTICAL_PAD);

    this.addActor(hudTable);
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:29,代码来源:HudMenu.java

示例2: initPlayerButton

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
private void initPlayerButton() {
    playerButton = new Button(new Button.ButtonStyle());
    playerButton.setWidth(460);
    playerButton.setHeight(360);
    playerButton.setX(10);
    playerButton.setY(170);
    playerButton.setDebug(true);

    stage.addActor(playerButton);

    playerButton.addListener(new ClickListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            player.reactOnClick();
            game.addPoint();
            return super.touchDown(event, x, y, pointer, button);
        }
    });
}
 
开发者ID:BePeGames,项目名称:ClickerGame,代码行数:20,代码来源:GamePlayScreen.java

示例3: initResetButton

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
private void initResetButton() {
    resetButton = new Button(new Button.ButtonStyle());
    resetButton.setWidth(40);
    resetButton.setHeight(20);
    resetButton.setX(160);
    resetButton.setY(550);
    resetButton.setDebug(true);

    stage.addActor(resetButton);

    resetButton.addListener(new ClickListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            game.resetPoints();
            return super.touchDown(event, x, y, pointer, button);
        }
    });
}
 
开发者ID:BePeGames,项目名称:ClickerGame,代码行数:19,代码来源:GamePlayScreen.java

示例4: createMobileMoveButton

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
private void createMobileMoveButton() {
    float screenWidth = Gdx.graphics.getWidth();
    float screenHeight = Gdx.graphics.getHeight();

    moveButton = new Button(skin);
    moveButton.getStyle().down = new TextureRegionDrawable(AssetManager.getInstance().getTextureRegion("default")).tint(MOBILE_BUTTON_DOWN_COLOR);
    moveButton.getStyle().up = new TextureRegionDrawable(AssetManager.getInstance().getTextureRegion("default")).tint(MOBILE_BUTTON_UP_COLOR);
    moveButton.setSize(screenWidth * 0.35f, screenHeight * 0.2f);
    moveButton.setPosition(screenWidth / 32, screenHeight / 32f);
    moveButton.addListener(new com.badlogic.gdx.scenes.scene2d.InputListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            boolean isTutorial = DAO.getInstance().getBoolean(DAO.IS_NEW_KEY, true);
            if (Globals.getGameState() == Game.State.WAIT_FOR_INPUT) {
                Globals.setGameState(Game.State.RUNNING);
            }

            if (Globals.getGameState() == Game.State.RUNNING) {
                movePointer = pointer;
            }
            return true;
        }
    });

    stage.addActor(moveButton);
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:27,代码来源:HUD.java

示例5: getSettingsButton

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
protected Button getSettingsButton(boolean useText)
{
    Button button = useText
        ? new BeepingImageTextButton("Settings", UIManager.skin, "settings")
        : new BeepingImageButton(UIManager.skin, "settings");

    button.addListener(
        new ClickListener()
        {
            @Override
            public void clicked(InputEvent event, float x, float y)
            {
                ScreenManager.addScreen(new SettingsScreen());
            }
        });

    return button;
}
 
开发者ID:overengineering,项目名称:space-travels-3,代码行数:19,代码来源:Screen.java

示例6: doShow

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
@Override protected void doShow(String signInReasonKey) {
    Table content = new Table(Config.skin);
    content.setBackground("ui-store-window-background");
    content.defaults().pad(4);

    LocLabel label = new LocLabel(signInReasonKey);
    label.setWrap(true);
    label.setAlignment(Align.center);

    Button button = new Button(Config.skin);
    button.defaults().pad(2);
    button.add(new LocLabel("ui-sign-in")).padTop(1).padLeft(4).expand().right();
    button.add(new Tile("ui/button/services-icon")).padTop(4).padBottom(2).padRight(4).expand().left();
    button.addListener(new ChangeListener() {
        @Override public void changed(ChangeEvent event, Actor actor) {
            signIn = true;
            hide();
        }
    });

    content.add(label).width(130).row();
    content.add(button).width(70).padBottom(8);

    table.add(content);
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:26,代码来源:SignInWindow.java

示例7: HexaFrameBottom

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
public HexaFrameBottom(Skin hudSkin) {
    super();
    this.hudSkin = hudSkin;
    hexaFrameImage = new Image(hudSkin.getRegion(HEXA_FRAME_NAME));
    setWidth(hexaFrameImage.getWidth());
    setHeight(hexaFrameImage.getHeight());

    frameHiddenButton = new Button(hudSkin, "frame_bottom_hidden");
    frameHiddenButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            hide(false);
        }
    });
    frameHiddenButton.setPosition(0, 0);

    frameVisibleGroup.addActor(hexaFrameImage);
    addActor(frameVisibleGroup);
    addActor(frameHiddenButton);
}
 
开发者ID:RageGo,项目名称:RageGo,代码行数:21,代码来源:HexaFrameBottom.java

示例8: HEToolbox

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
public HEToolbox() {
  super(true);

  ButtonGroup<Button> toolButtons = new ButtonGroup<>();

  for (final ToolType type : ToolType.values()) {
    Button button = new VisTextButton(type.toString(), "toggle");
    button.addListener(new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            if (((Button) actor).isChecked()) {
              HelixEditor.getInstance().getToolbarState().setActiveTool(type);
            }
          }
        });

    toolButtons.add(button);

    add(button).padBottom(-8);

    row();
  }
}
 
开发者ID:fauu,项目名称:HelixEngine,代码行数:24,代码来源:HEToolbox.java

示例9: addButton

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
public void addButton(LabelStyle style, String label, String secondaryLabel, Runnable action, boolean active) {
  Button b = new Button(skin.get(ButtonStyle.class));
  if (action != null)
    b.addListener(new ChangeListener() {
      @Override
      public void changed(ChangeEvent event, Actor actor) {
        action.run();
      }
    });
  b.setDisabled(!active);

  b.add(new Label(label, style)).left();
  if (secondaryLabel != null && !secondaryLabel.isEmpty())
    b.add(new Label(secondaryLabel, style)).padRight(15f);

  table.add(b).minHeight(b.getMinHeight()).prefHeight(b.getPrefHeight()).left().padLeft(1f).colspan(nbColumns);
  table.row();
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:19,代码来源:FramedMenu.java

示例10: addButtonSprite

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
/**
 * Adds a button to the menu, with an icon on the left and label on the right.
 */
public Button addButtonSprite(Drawable icon, String label, Runnable action, boolean active) {
  LabelStyle style = active ? skin.get(LabelStyle.class) : skin.get("inactive", LabelStyle.class);

  Button b = new Button(skin.get(ButtonStyle.class));
  if (action != null)
    b.addListener(new ChangeListener() {
      @Override
      public void changed(ChangeEvent event, Actor actor) {
        action.run();
      }
    });
  b.setDisabled(!active);

  b.add(new Image(icon, Scaling.fit)).left();
  Label l = new Label(label, style);
  l.setWrap(true);
  b.add(l).padLeft(8).right().expandX().fillX();

  table.add(b).minHeight(b.getMinHeight()).prefHeight(b.getPrefHeight()).left().padLeft(1f).colspan(nbColumns);
  table.row();

  return b;
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:27,代码来源:FramedMenu.java

示例11: buildNotificationMenu

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
public void buildNotificationMenu() {
  List<Notification> notifs = notifications.getNotifications();
  notifMenu.clear();
  if (notifs.isEmpty())
    notifMenu.addLabel("No notifications");
  else
    for (Notification n : notifs) {
      Button b = notifMenu.addButtonSprite(n.type, n.msg, () -> {
        inputManager.reloadMenus();
        if (n.action != null)
          n.action.run();
      }, true);
      b.addListener(new ClickListener(Buttons.RIGHT) {
        @Override
        public void clicked(InputEvent event, float x, float y) {
          notifications.discard(n);
          inputManager.reloadMenus();
        }
      });
    }
  notifMenu.addToStage(stage, Gdx.graphics.getWidth() - 400, min(512, notifMenu.getTable().getPrefHeight()), false);
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:23,代码来源:MenuBuilder.java

示例12: LootPopup

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
/**
 * Konstruktor.
 * 
 * @param loots
 *            Liste alles Loots, die angezeigt werden sollen.
 */
public LootPopup(final HashSet<Lootable> loots) {
	super();

	Label label = createLabel("Deine gesammelten Gegenstände");
	// label.setWidth(popupWidth - 80);
	// label.setWrap(true);
	// label.layout();
	addActor(label);

	LootDisplay button = new LootDisplay(loots, lootPopupHeight,
			popupWidth - 80);
	addActor(button);

	Button ok = createButton("OK");
	ok.addListener(new ChangeListener() {

		@Override
		public void changed(final ChangeEvent event, final Actor actor) {
			LootPopup.this.getOverlay().disposePopup();
			event.cancel();
		}
	});
	addActor(ok);
}
 
开发者ID:PhilippGrulich,项目名称:HAW-SE2-projecthorse,代码行数:31,代码来源:LootPopup.java

示例13: CityPopup

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
/**
 * Konstruktor.
 * 
 * @param cityObject
 *            CityInfos.
 */
public CityPopup(final CityObject cityObject) {
	Label label = createLabel(gennerateText(cityObject.getCityInfo()));
	ScrollPane scollContent = new DefaultScrollPane(label, height / 3, popupWidth * 0.8f);

	this.addActor(createLabel(cityObject.getCityName()));

	this.addActor(scollContent);
	Button btn = new ButtonLarge("Ok");
	btn.addListener(new ChangeListener() {

		@Override
		public void changed(final ChangeEvent event, final Actor actor) {
			getOverlay().disposePopup();
		}

	});
	this.addActor(btn);
}
 
开发者ID:PhilippGrulich,项目名称:HAW-SE2-projecthorse,代码行数:25,代码来源:CityPopup.java

示例14: TutorialPopup

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
/**
 * Der default Konstruktor.
 */
public TutorialPopup() {

	Label label = createLabel(gennerateText());
	ScrollPane scollContent = new DefaultScrollPane(label,
			tutorialPopupHeight, popupWidth * 0.8f);

	this.addActor(createLabel("Anleitung :)"));

	this.addActor(scollContent);
	Button btn = new ButtonLarge("Los");
	btn.addListener(new ChangeListener() {

		@Override
		public void changed(final ChangeEvent event, final Actor actor) {
			getOverlay().disposePopup();
		}

	});
	this.addActor(btn);

}
 
开发者ID:PhilippGrulich,项目名称:HAW-SE2-projecthorse,代码行数:25,代码来源:TutorialPopup.java

示例15: addTab

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
public void addTab(String name, Actor panel) {
	Button button = new TextButton(name, skin);
	buttonGroup.add(button);
	header.addActor(button);
	tabs.add(new Tab(button, panel));
	
	button.addListener(new ClickListener() {
		
		@Override
		public void clicked (InputEvent event, float x, float y) {
			setTab((Button)event.getListenerActor());
		}
	});
	
	if(tabs.size() == 1)
		setTab(0);
}
 
开发者ID:bladecoder,项目名称:bladecoder-adventure-engine,代码行数:18,代码来源:TabPanel.java


注:本文中的com.badlogic.gdx.scenes.scene2d.ui.Button.addListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。