本文整理匯總了Java中com.badlogic.gdx.scenes.scene2d.ui.TextButton.addListener方法的典型用法代碼示例。如果您正苦於以下問題:Java TextButton.addListener方法的具體用法?Java TextButton.addListener怎麽用?Java TextButton.addListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.scenes.scene2d.ui.TextButton
的用法示例。
在下文中一共展示了TextButton.addListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addTab
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
public void addTab(String tabTitle, final ITabContent tabContent,
Skin skin) {
TextButton button = new TextButton(tabTitle, skin);
button.align(Align.left);
//button.setFillParent(true);
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
tabContent.setContent(content);
content.pack();
setWidth(preferedContentWidth);
setHeight(preferedContentHeight);
}
});
tabHeaders.add(button);
contents.add(tabContent);
preferedContentWidth = Math.max(preferedContentWidth, tabContent.getWidth());
preferedContentHeight = Math.max(preferedContentHeight, tabContent.getHeight() + tabHeaders.get(0).getHeight());
}
示例2: ObjectiveDialog
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
public ObjectiveDialog(Skin skin, Hexpert hexpert) {
super(hexpert, skin);
getBackground().setMinWidth(1000);
final TextButton textButtonOK = new TextButton(hexpert.i18NBundle.get("ok"), skin);
textButtonOK.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
textButtonOK.setChecked(false);
}
});
setObject(textButtonOK, null);
getButtonTable().add(textButtonOK);
getContentTable().defaults().pad(5, 0, 5, 15);
getContentTable().top();
}
示例3: SingleplayerSaveDeleteMenu
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
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);
}
示例4: createSignInBtn
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
/**
* Adds the Sign In / Sign Out Button to the Networking Menu.
*
* @param table The table to where the button will be added.
*/
private void createSignInBtn(Table table) {
final TextButton signInButton = new TextButton(
gameServices.isSignedIn() ? "Sign Out" : "Sign In!", skin1);
signInButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (gameServices.isSignedIn()) {
gameServices.signOut();
signInButton.setText("Sign In!");
} else {
gameServices.signIn();
signInButton.setText("Sign Out");
}
}
});
table.add(signInButton).size(BUTTON_WIDTH, DEFAULT_BUTTON_SIZE).pad(BUTTON_EDGE).row();
}
示例5: GameDialog
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
public GameDialog(Skin skin) {
super("", skin);
waveLevel = new Label("", skin);
monsHP = new Label("", skin);
monsBonus = new Label("", skin);
monsSpeed = new Label("", skin);
monsNumber = new Label("", skin);
btnOK = new TextButton("Okay, Let them come!", skin);
btnOK.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
// TODO Auto-generated method stub
setVisible(false);
}
});
setTitle(" There are more monsters are coming to you... ");
}
示例6: init
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
private void init() {
// Make the window around 3/4 of the screen
setSize(width, height);
// Position window in the middle
setPosition(Gdx.graphics.getWidth() / 2 - getWidth() / 2, Gdx.graphics.getHeight() / 2 - getHeight() / 2);
// Center title
getTitleLabel().setAlignment(Align.center);
// Create the close button
if (getTitleLabel().getText().length != 0) {
closeButton = new TextButton("X", getSkin());
closeButton.setSize(20, 20);
closeButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
closeButton.setChecked(false);
close();
}
});
getTitleTable().addActor(closeButton);
closeButton.setPosition(getWidth() - closeButton.getWidth() - 5, 0);
}
getTitleTable().getCells().get(0).expandY().fillY();
setMovable(false);
setModal(true);
row();
}
示例7: getActor
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
public Actor getActor(final VisualSettingManager visualSettingManager) {
final TextButton textButton = new TextButton(Localization.get("menu.settings.open_group"), visualSettingManager.getSkin());
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
visualSettingManager.setSettingGroup(SettingGroup.this);
}
});
return textButton;
}
示例8: PlayProgressCardWindow
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
public PlayProgressCardWindow(String title, Skin skin, List<ProgressCardType> hand, GamePhase currentPhase, boolean isMyTurn, boolean firstBarbarianAttack) {
super(title, skin);
if (hand.isEmpty()) {
add(new Label("Your hand is empty", skin)).pad(10);
}
// adds images of the card and the associated button that will play the card
for (ProgressCardType type : hand) {
Table cardTable = new Table(CatanGame.skin);
// TODO: add image of correct progress card
// cardTable.add(cardMap.get(type)).padBottom(10).row();
TextButton playCard = new TextButton("Play " + type.toString().toLowerCase(), CatanGame.skin);
playCard.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (playProgressCardListener != null) {
playProgressCardListener.onCardChosen(type);
remove();
}
}
});
playCard.setDisabled(!isLegalPlay(type, currentPhase, isMyTurn, firstBarbarianAttack));
cardTable.add(playCard).pad(5);
add(cardTable).pad(5);
}
pack();
// set position on screen
setPosition(Gdx.graphics.getWidth() / 2 - getWidth() / 2, Gdx.graphics.getHeight() / 2 - getHeight() / 2);
// enable moving the window
setMovable(true);
}
示例9: addExitButton
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
/**
* Adds the Exit Button to the Main Menu.
*
* @param table The table to where the Exit button will be added.
*/
private void addExitButton(Table table) {
TextButton exitButton = new TextButton("Exit", skin1);
exitButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Gdx.app.exit();
}
});
table.add(exitButton).size(BUTTON_WIDTH, DEFAULT_BUTTON_SIZE).pad(BUTTON_EDGE).row();
}
示例10: addNetworkingButton
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
/**
* Adds the Networking Button to the Main Menu.
*
* @param table The table to where the Networking button will be added.
*/
private void addNetworkingButton(Table table) {
TextButton networkingButton = new TextButton("Networking", skin1);
networkingButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new NetworkingMenuScreen(game));
}
});
table.add(networkingButton).size(BUTTON_WIDTH, DEFAULT_BUTTON_SIZE).pad(BUTTON_EDGE).row();
}
示例11: show
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
@Override
public void show() {
super.show();
background = new Texture("theme/basic/ui/Window.png");
final TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
textButtonStyle.font = game.getFonts().get("moonhouse64");
textButtonStyle.up = new TextureRegionDrawable(new TextureRegion(background));
Table table = new Table();
table.setSize(viewport.getWorldWidth(), viewport.getWorldHeight());
//Unlock achievement button
TextButton achievementButton = new TextButton("Unlock Achievement", textButtonStyle);
achievementButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if(TDGalaxy.onlineServices != null)
TDGalaxy.onlineServices.unlockAchievement(Constants.ACHIEVEMENT_NO_LIFE);
}
});
table.add(achievementButton);
table.center();
stage.addActor(table);
}
示例12: ServerSetupMenu
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
public ServerSetupMenu(final Save save) {
super();
title = new Label(Localization.get("menu.server.title"), skin.get("title", Label.LabelStyle.class));
saveLabel = new Label(Localization.get("menu.server.save", save.name), skin);
saveLabel.setAlignment(Align.center);
port = new TextField("", skin);
port.setMessageText(
Localization.get("menu.server.port", Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)));
port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
start = new TextButton(Localization.get("menu.server.start"), skin);
back = MenuTools.getBackButton(this);
start.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
int p = port.getText().isEmpty() ? Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)
: Integer.parseInt(port.getText());
Adapter.setMenu(new ServerRunningMenu(save, p));
}
});
stage.addActor(title);
stage.addActor(saveLabel);
stage.addActor(port);
stage.addActor(start);
stage.addActor(back);
}
示例13: addResumeBtn
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
/**
* Function that adds a Resume Button to the Stage.
*/
protected void addResumeBtn() {
TextButton resumeBtn = new TextButton("Resume", skin);
resumeBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
togglePause();
}
});
table.add(resumeBtn).size(BUTTON_WIDTH, BUTTON_HEIGHT).padBottom(BUTTON_DISTANCE).row();
}
示例14: addExitBtn
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
/**
* Function that adds an Exit Button to the Stage.
*/
protected void addExitBtn() {
TextButton exitBtn = new TextButton("Exit", this.skin);
exitBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new LevelMenuScreen(game));
}
});
table.add(exitBtn).size(BUTTON_WIDTH, BUTTON_HEIGHT);
}
示例15: SingleplayerSaveCreateMenu
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //導入方法依賴的package包/類
public SingleplayerSaveCreateMenu() {
super();
title = new Label(Localization.get("menu.singleplayer.create.title"), skin.get("title", Label.LabelStyle.class));
name = new TextField("", skin);
name.setMessageText(Localization.get("menu.singleplayer.create.name"));
name.setTextFieldFilter(new TextField.TextFieldFilter() {
@Override
public boolean acceptChar(TextField textField, char c) {
return c >= 0x20 && c < 0x7F;
}
});
generator = new SelectBox<SaveTypeDisplay>(skin);
String[] types = GeneratorManager.ids();
SaveTypeDisplay[] display = new SaveTypeDisplay[types.length];
for (int i = 0; i < types.length; i++) {
display[i] = new SaveTypeDisplay(types[i]);
}
generator.setItems(display);
mode = new SelectBox<Gamemode>(skin);
mode.setItems(Gamemode.values());
seed = new TextField("", skin);
seed.setMessageText(Localization.get("menu.singleplayer.create.seed"));
start = new TextButton(Localization.get("menu.singleplayer.create.start"), skin);
back = MenuTools.getBackButton(this);
start.addListener(startListener = new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Adapter.setMenu(new SingleplayerLoadingMenu(ClientSaveManager.createSave(name.getText(), generator.getSelected().id, mode.getSelected(), seed.getText())));
}
});
stage.addActor(title);
stage.addActor(name);
stage.addActor(generator);
stage.addActor(mode);
stage.addActor(seed);
stage.addActor(start);
stage.addActor(back);
}