本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.SelectBox.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java SelectBox.addListener方法的具体用法?Java SelectBox.addListener怎么用?Java SelectBox.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.ui.SelectBox
的用法示例。
在下文中一共展示了SelectBox.addListener方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getActor
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; //导入方法依赖的package包/类
@Override
public Actor getActor(VisualSettingManager visualSettingManager) {
final SelectBox<String> selectBox = new SelectBox<String>(visualSettingManager.getSkin());
selectBox.setItems(options);
selectBox.setSelected(selected);
selectBox.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
if (!(event instanceof SettingsMenu.SaveEvent))
return false;
set(selectBox.getSelected());
return true;
}
});
return selectBox;
}
示例2: createDropdown
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; //导入方法依赖的package包/类
private void createDropdown() {
final float screenWidth = Gdx.graphics.getWidth();
final float screenHeight = Gdx.graphics.getHeight();
final SelectBox<String> dropdown = new SelectBox<String>(skin);
dropdown.setSize(screenWidth, screenHeight / 10);
dropdown.setPosition(0, screenHeight - dropdown.getHeight());
dropdown.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
inputListener.setSelectedEffectType(dropdown.getSelected());
}
});
// Load dropdown.
Array<String> effectTypes = ParticleEffectManager.getInstance().getParticleEffectTypes();
dropdown.setItems(effectTypes);
dropdown.getStyle().font = font;
stage.addActor(dropdown);
}
示例3: addSelectBox
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; //导入方法依赖的package包/类
public <E> void addSelectBox(String label, E selected, E[] values, Consumer<E> lis) {
LabelStyle style = skin.get(LabelStyle.class);
Label l = new Label(label, style);
table.add(l).minHeight(l.getMinHeight()).prefHeight(l.getPrefHeight());
SelectBox<E> sb = new SelectBox<E>(skin.get(SelectBoxStyle.class));
sb.setItems(values);
sb.setSelected(selected);
sb.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
lis.accept(sb.getSelected());
}
});
Cell<SelectBox<E>> right = table.add(sb).minHeight(sb.getMinHeight()).prefHeight(sb.getMinHeight());
if (nbColumns > 2)
right.colspan(nbColumns - 1);
table.row();
}
示例4: addBooleanSelectBox
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; //导入方法依赖的package包/类
public void addBooleanSelectBox(String label, boolean selected, Consumer<Boolean> lis) {
LabelStyle style = skin.get(LabelStyle.class);
Label l = new Label(label, style);
table.add(l).minHeight(l.getMinHeight()).prefHeight(l.getPrefHeight());
SelectBox<Boolean> sb = new SelectBox<Boolean>(skin.get(SelectBoxStyle.class));
sb.setItems(Boolean.TRUE, Boolean.FALSE);
sb.setSelected(selected);
sb.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
lis.accept(sb.getSelected());
}
});
Cell<SelectBox<Boolean>> right = table.add(sb).minHeight(sb.getMinHeight()).prefHeight(sb.getMinHeight());
if (nbColumns > 2)
right.colspan(nbColumns - 1);
table.row();
}
示例5: addProperty
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; //导入方法依赖的package包/类
public void addProperty(String name, String selected, String[] value) {
table.row();
table.add(new Label(name, skin)).expandX().left();
SelectBox<String> sb = new SelectBox<String>(skin);
sb.setItems(value);
if (selected != null)
sb.setSelected(selected);
sb.setName(name);
table.add(sb).expandX().left();
sb.addListener(new ChangeListener() {
@SuppressWarnings("unchecked")
@Override
public void changed(ChangeEvent event, Actor actor) {
updateModel(actor.getName(), ((SelectBox<String>) actor).getSelected());
}
});
}
示例6: setupUI
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; //导入方法依赖的package包/类
private void setupUI() {
stage = new Stage(new ScreenViewport(), quad2dBatch);
skin = new Skin(Gdx.files.internal("uiskin.json"));
final SelectBox<Test> selectBox = new SelectBox<Test>(skin);
selectBox.setItems(Test.values());
selectBox.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
test = selectBox.getSelected();
elapsed = 0;
}
});
Table table = new Table();
table.setFillParent(true);
table.defaults().padTop(5).left();
table.top().left().padLeft(5);
table.add(selectBox).row();
table.add(new Label("", skin) {
int fps = -1;
public void act(float delta) {
super.act(delta);
if (Gdx.graphics.getFramesPerSecond() != fps) {
fps = Gdx.graphics.getFramesPerSecond();
setText("" + fps);
}
}
}).row();
stage.addActor(table);
}
示例7: getActor
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; //导入方法依赖的package包/类
@Override
public Actor getActor(VisualSettingManager visualSettingManager) {
final SelectBox<String> selectBox = new SelectBox<String>(visualSettingManager.getSkin());
selectBox.setItems(options);
selectBox.setSelected(selected);
selectBox.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
if (!(event instanceof SettingsMenu.SaveEvent)) return false;
set(selectBox.getSelected());
return true;
}
});
return selectBox;
}
示例8: NoiseSamplerForm
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; //导入方法依赖的package包/类
public NoiseSamplerForm(Skin skin, AbstractSampler sampler, Samplers pool) {
super(skin, sampler, pool);
this.skin = skin;
defaults().center().pad(5);
setBackground(Styles.INNER_BACKGROUND);
Label algorithmLabel = new Label("algorithm", skin);
add(algorithmLabel);
algorithmSelect = new SelectBox(skin);
String[] algorithmNames = new String[Editor.KNOWN_ALGORITHMS.keySet().size()];
Editor.KNOWN_ALGORITHMS.keySet().toArray(algorithmNames);
algorithmSelect.setItems(algorithmNames);
algorithmSelect.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
notifyChanges();
}
});
add(algorithmSelect);
loadFromConfig(sampler.getConfig());
notifyChanges();
}
示例9: ColorAttributeForm
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; //导入方法依赖的package包/类
public ColorAttributeForm(Skin skin, String title, final ColorAttribute colorAttribute, final ColorAttributeChangeListener listener) {
super(skin, title, colorAttribute.color, new ColorChangeListener() {
@Override
public void onColorChange(float r, float g, float b) {
colorAttribute.color.r = r;
colorAttribute.color.g = g;
colorAttribute.color.b = b;
listener.onColorAttributeChange(colorAttribute);
}
}, null);
row();
add(new Label("Attribute", skin));
final SelectBox<String> attributeSelection = new SelectBox<String>(skin);
attributeSelection.setItems(
ColorAttribute.DiffuseAlias,
ColorAttribute.SpecularAlias,
ColorAttribute.AmbientAlias,
ColorAttribute.EmissiveAlias,
ColorAttribute.ReflectionAlias,
ColorAttribute.AmbientLightAlias,
ColorAttribute.FogAlias
);
attributeSelection.setSelected(ColorAttribute.DiffuseAlias);
attributeSelection.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
String selectedType = attributeSelection.getSelected();
long attributeType = ColorAttribute.getAttributeType(selectedType);
listener.onColorAttributeChange(new ColorAttribute(attributeType, colorAttribute.color));
}
});
add(attributeSelection);
titleLabel.setText("ColorAttribute");
pad(10);
pack();
}