本文整理了Java中com.badlogic.gdx.scenes.scene2d.ui.Button.addListener()
方法的一些代码示例,展示了Button.addListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.addListener()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.ui.Button
类名称:Button
方法名:addListener
暂无
代码示例来源:origin: libgdx/libgdx
private void initialize () {
setTouchable(Touchable.enabled);
addListener(clickListener = new ClickListener() {
public void clicked (InputEvent event, float x, float y) {
if (isDisabled()) return;
setChecked(!isChecked, true);
}
});
addListener(new FocusListener() {
public void keyboardFocusChanged (FocusEvent event, Actor actor, boolean focused) {
Button.this.focused = focused;
}
});
}
代码示例来源:origin: libgdx/libgdx
private void initialize () {
setTouchable(Touchable.enabled);
addListener(clickListener = new ClickListener() {
public void clicked (InputEvent event, float x, float y) {
if (isDisabled()) return;
setChecked(!isChecked, true);
}
});
addListener(new FocusListener() {
public void keyboardFocusChanged (FocusEvent event, Actor actor, boolean focused) {
Button.this.focused = focused;
}
});
}
代码示例来源:origin: libgdx/libgdx
button0.addListener(new ChangeListener(){
public void changed (ChangeEvent event, Actor actor) {
boolean continuous = Gdx.graphics.isContinuousRendering();
button1.addListener(new ChangeListener(){
public void changed (ChangeEvent event, Actor actor) {
new Thread(new Runnable(){
button2.addListener(new ChangeListener(){
public void changed (ChangeEvent event, Actor actor) {
final Graphics graphics = Gdx.graphics; // caching necessary to ensure call on this window
button3.addListener(new ChangeListener(){
public void changed (ChangeEvent event, Actor actor) {
Timer.schedule(new Task(){
button4.addListener(new ChangeListener(){
public void changed (ChangeEvent event, Actor actor) {
stage.addAction(Actions.sequence(Actions.delay(2), Actions.run(new Runnable(){
button5.addListener(new ChangeListener(){
public void changed (ChangeEvent event, Actor actor) {
final Graphics graphics = Gdx.graphics; // caching necessary to ensure call on this window
代码示例来源:origin: libgdx/libgdx
private void setupUI () {
ui = new Stage(new ExtendViewport(640, 480));
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
skipCleanup = new CheckBox("Skip blend function clean-up", skin);
skipCleanup.addListener(listener);
logLabel = new Label("", skin.get(LabelStyle.class));
clearEmitters = new TextButton("Clear screen", skin);
clearEmitters.addListener(listener);
scaleEffects = new TextButton("Scale existing effects", skin);
scaleEffects.addListener(listener);
Table table = new Table();
table.setTransform(false);
table.setFillParent(true);
table.defaults().padTop(5).left();
table.top().left().padLeft(5);
table.add(skipCleanup).colspan(2).row();
table.add(clearEmitters).spaceRight(10);
table.add(scaleEffects).row();
table.add(logLabel).colspan(2);
ui.addActor(table);
}
代码示例来源:origin: libgdx/libgdx
passwordTextField.setPasswordMode(true);
buttonMulti.addListener(new TextTooltip(
"This is a tooltip! This is a tooltip! This is a tooltip! This is a tooltip! This is a tooltip! This is a tooltip!",
skin));
tooltipTable.pad(10).background("default-round");
tooltipTable.add(new TextButton("Fancy tooltip!", skin));
imgButton.addListener(new Tooltip(tooltipTable));
代码示例来源:origin: com.badlogicgames.gdx/gdx
private void initialize () {
setTouchable(Touchable.enabled);
addListener(clickListener = new ClickListener() {
public void clicked (InputEvent event, float x, float y) {
if (isDisabled()) return;
setChecked(!isChecked, true);
}
});
addListener(new FocusListener() {
public void keyboardFocusChanged (FocusEvent event, Actor actor, boolean focused) {
Button.this.focused = focused;
}
});
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
private void initializeListeners() {
findButton("replaceScreen1").addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
ReplaceScreenOne screenOne = new ReplaceScreenOne(game);
game.replaceTopScreen(screenOne);
}
});
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
private void addBackButtonListener(final AbstractGame game) {
Button backButton = findButton("backButton");
if (backButton != null) {
backButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.backToPreviousScreen();
}
});
}
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
private void initializeListeners() {
findButton("replaceScreen2").addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
ReplaceScreenTwo screenTwo = new ReplaceScreenTwo(game);
game.replaceTopScreen(screenTwo);
}
});
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
private void initializeListeners() {
findButton("addScreen1").addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
ReplaceScreenOne screenOne = new ReplaceScreenOne(game);
game.addScreen(screenOne);
}
});
findButton("addScreen2").addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
ReplaceScreenTwo screenTwo = new ReplaceScreenTwo(game);
game.addScreen(screenTwo);
}
});
}
代码示例来源:origin: kotcrab/vis-ui
public void setButton (ButtonType type, Button button, ChangeListener listener) {
if (type == null) throw new IllegalArgumentException("type can't be null");
if (button == null) throw new IllegalArgumentException("button can't be null");
if (buttons.containsKey(type.id)) buttons.remove(type.id);
buttons.put(type.id, button);
if (listener != null) button.addListener(listener);
}
代码示例来源:origin: kotcrab/vis-ui
/** Validates if given button (usually checkbox) is checked. Use VisCheckBox to additionally support error border around it. */
public void checked (Button button, String errorMsg) {
buttons.add(new CheckedButtonWrapper(button, true, errorMsg));
button.addListener(changeListener);
validate();
}
代码示例来源:origin: kotcrab/vis-ui
/** Validates if given button (usually checkbox) is unchecked. Use VisCheckBox to additionally support error border around it. */
public void unchecked (Button button, String errorMsg) {
buttons.add(new CheckedButtonWrapper(button, false, errorMsg));
button.addListener(changeListener);
validate();
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
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);
}
代码示例来源:origin: narfman0/GDXWorld
/** builds {@link #chooseButton}, {@link #cancelButtonListener}, {@link #tree}, {@link #treePane} */
protected void buildWidgets() {
(tree = new Tree(style.treeStyle)).addListener(treeListener);
if(style.scrollPaneStyle != null)
treePane = new ScrollPane(tree, style.scrollPaneStyle);
else
treePane = new ScrollPane(tree);
(chooseButton = Scene2DUtils.newButton(style.selectButtonStyle, "select")).addListener(chooseButtonListener);
chooseButton.setDisabled(true);
(cancelButton = Scene2DUtils.newButton(style.cancelButtonStyle, "cancel")).addListener(cancelButtonListener);
}
代码示例来源:origin: narfman0/GDXWorld
public AbstractLightTable(Skin skin, final LightWindow lightWindow,
Color color, int rays){
this.skin = skin;
colorTable = new ColorTable(color, skin);
raysField = new TextField(rays+"", skin);
raysField.setMessageText("<ray count>");
final AbstractLightTable selected = this;
selectButton = new TextButton("Select", skin);
selectButton.addListener(new ClickListener() {
@Override public void clicked(InputEvent event, float x, float y) {
lightWindow.setSelected(selected);
}
});
}
代码示例来源:origin: narfman0/GDXWorld
private void addTable(Skin skin, AbstractQuestTrigger trigger){
TriggerTable table = createTable(trigger);
Table parentTable = new Table(skin);
tables.add(table);
parentTable.add(table);
final Button deleteButton = new TextButton("Delete", skin);
deleteButton.addListener(new ClickListener() {
@Override public void clicked(InputEvent event, float x, float y) {
contents.removeActor(parentTable);
tables.remove(table);
contents.pack();
}
});
parentTable.add(deleteButton);
contents.add(parentTable);
contents.row();
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
public PieMenu2(SceneScreen scr) {
sceneScreen = scr;
font = scr.getUI().getSkin().getFont("desc");
buttons = new Button[NUM_VERBS];
endPositions = new Vector2[NUM_VERBS];
for(int i = 0; i < NUM_VERBS; i++) {
buttons[i] = new Button(scr.getUI().getSkin(), "pie_lookat");
endPositions[i] = new Vector2();
addActor(buttons[i]);
buttons[i].addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, com.badlogic.gdx.scenes.scene2d.Actor actor) {
if (iActor != null) {
sceneScreen.runVerb(iActor, "lookat", null);
}
hide();
}
});
}
}
代码示例来源:origin: Var3D/var3dframe
@Override
public void init() {
//设置背景
setBackground(Color.DARK_GRAY);
//创建标题
VLabel lab_title = game.getLabel("非等比例舞台").setPosition(getWidth() / 2, getTop() - 10, Align.top).touchOff().show();
//关闭按钮
Button btn_close = game.getTextButton("关闭", Color.WHITE, Color.valueOf("ff2266"))
.setSize(100, 40).addClicAction().setPosition(getWidth() / 2, 50, Align.bottom).show();
btn_close.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
//舞台其实不能关闭,只能跳转
game.setStage(StageStages.class);
}
});
}
代码示例来源:origin: Var3D/var3dframe
@Override
public void init() {
//设置背景
setBackground(400, 300, Color.valueOf("0075ed"));
//设置标题
game.getLabel("等比例对话框").touchOff().setFontScale(1.3f).setPosition(getWidth() / 2, getHeight() - 30, Align.top).show();
//关闭按钮
Button btn_close = game.getTextButton("关闭", Color.WHITE, Color.valueOf("ff2266"))
.setSize(100, 40).addClicAction().setPosition(getWidth() / 2, 50, Align.bottom).show();
btn_close.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
//game.removeDialog(DialogRatio.this);
game.removeDialog();//新的移除当前dialog方法,可以不带this参数
}
});
}
内容来源于网络,如有侵权,请联系作者删除!