本文整理匯總了Java中com.badlogic.gdx.scenes.scene2d.EventListener類的典型用法代碼示例。如果您正苦於以下問題:Java EventListener類的具體用法?Java EventListener怎麽用?Java EventListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EventListener類屬於com.badlogic.gdx.scenes.scene2d包,在下文中一共展示了EventListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createSlider
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
public VisSlider createSlider(String label, float minimum, float maximum, float[] snapValues, float threshold, float initialValue, ChangeListener changeListener) {
if(!label.isEmpty()) {
add(new VisLabel(label)).left().padRight(10).padTop(20);
}
add(new VisLabel((int)minimum + "")).padRight(5).padTop(20);
VisSlider slider = new VisSlider(minimum, maximum, 1, false);
slider.setSnapToValues(snapValues, threshold);
slider.setValue(initialValue);
slider.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
event.stop();
return false;
}
});
slider.addListener(changeListener);
add(slider).expandX().fill().padRight(5).padTop(20);
add(new VisLabel("" + (int)maximum)).padTop(20).row();
return slider;
}
示例2: ServerRunningMenu
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
public ServerRunningMenu(Save save, int port) {
super(Localization.get("menu.general.loading"), Localization.get("menu.server.stop"));
this.save = save;
this.port = port;
addButtonListener(new EventListener() {
@Override
public boolean handle(Event event) {
if (!(event instanceof ChangeListener.ChangeEvent)) return false;
try {
Adapter.gotoMainMenu();
} catch (StopLoopException ignored) {
}
return true;
}
});
}
示例3: getActor
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的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;
}
示例4: create
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
public void create() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
//font = new BitmapFont();
//skin = new Skin();
//buttonAtlas = new TextureAtlas(Gdx.files.internal());
//skin.addRegions(buttonAtlas);
button = new Button();
button.setStyle(new Button.ButtonStyle());
button.addCaptureListener(new EventListener() {
@Override
public boolean handle(Event event) {
Gdx.app.log("LOG", "event " + event);
return false;
}
});
stage.addActor(button);
}
示例5: init
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
private void init(){
// Vector2 point = localToStageCoordinates(new Vector2(getX(), getY()));//TODO
//
// if(chooseTransparent != null) chooseTransparent.setBounds(point.x + borderSize, point.y + borderSize, //if() - button not empty
// getWidth() - borderSize * 2, getHeight() - borderSize * 2);
// if(cdText != null) cdText.setBounds(getX() + borderSize, getY() + borderSize,
// getWidth() - borderSize * 2, getHeight() - borderSize * 2);
// System.out.println(getX() + " " + getY() + " " + getWidth() + " " + getHeight());
for (EventListener l:getListeners()) {
if (l instanceof TooltipListener) {
((SpellTooltip) ((TooltipListener) l).getTooltip()).init(getStage());
}
if(l instanceof SpellButton.SpellThrower){
((SpellButton.SpellThrower) l).init(getStage());
}
}
}
示例6: notifyListeners
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
private void notifyListeners(){
gradeTowerSlot.getSlot().notifyListeners();
for (int i = 0; i < g.length; i++){
for (Actor a:g[i].getChildren()){
for (EventListener t:a.getListeners()){
if(t instanceof TooltipListener){
((TooltipListener) t).getTooltip().hasChanged();
((TooltipListener) t).getTooltip().pack();
}
}
if(a instanceof GemGradeButton){
((GemGradeButton) a).update();
}
}
}
}
示例7: GestureButton
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
public GestureButton(String styleName, ViewManager viewManager) {
style = VisUI.getSkin().get(styleName, GestureButtonStyle.class);
style.checked = style.select;
filterStyle = new GestureButtonStyle();
filterStyle.down = style.down;
filterStyle.checked = style.checked;
filterStyle.up = style.up;
if (style.downFiltered != null) filterStyle.down = style.downFiltered;
if (style.selectFilterd != null) filterStyle.checked = style.selectFilterd;
if (style.upFiltered != null) filterStyle.up = style.upFiltered;
this.viewManager = viewManager;
this.setStyle(style);
this.ID = idCounter++;
buttonActions = new ArrayList<>();
//remove all Listeners
Array<EventListener> listeners = this.getListeners();
for (EventListener listener : listeners) {
this.removeListener(listener);
}
this.addCaptureListener(gestureListener);
this.pack();
}
示例8: place
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
private void place(Creature creature, int x, int y) {
WorldObjectView spawnView = dieToIconToSpawn.get(creature.description);
placed.add(creature);
refreshStartButton();
world.add(x, y, creature);
WorldObjectView worldView = world.getController(ViewController.class).getView(creature);
EventListener listener = createMoveSpawnedListener(creature, worldView, spawnView);
EventListener prev = moveListeners.remove(worldView);
if (prev != null) {
worldView.removeListener(prev);
}
moveListeners.put(worldView, listener);
worldView.addListener(listener);
spawnView.getColor().a = 0f;
spawnView.setTouchable(Touchable.disabled);
}
示例9: addTab
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
public void addTab(Actor header, Actor content) {
if (listeners.containsKey(header))
throw new IllegalArgumentException("header already exists");
headers.add(header);
contents.add(content);
super.addActor(header);
if (selectedIndex == -1)
setSelectedIndex(0);
invalidate();
final int index = headers.size - 1;
EventListener listener = new ClickListener() {
@Override public void clicked(InputEvent event, float x, float y) {
setSelectedIndex(index);
event.cancel();
}
};
header.addListener(listener);
listeners.put(header, listener);
}
示例10: start
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
@Override public void start(Callback callback) {
Stage stage = resources.get("stage");
EventListener listener = resources.getIfExists("restrictCloseWindowsListener");
if (listener != null) {
stage.removeCaptureListener(listener);
}
if (windowClass == null) {
callback.taskEnded();
return;
}
listener = new WindowListener() {
@Override protected void hide(WindowEvent event) {
if (!windowClass.isInstance(event.getWindow())) {
event.cancel();
}
}
};
stage.addCaptureListener(listener);
resources.put("restrictCloseWindowsListener", listener);
callback.taskEnded();
}
示例11: process
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
@Override
public void process(final LmlParser parser, final LmlTag tag, Actor actor, final String rawAttributeData) {
// Due to ListView tricky structure we should dig a little to get to the scrollable actor
if (actor instanceof ListView.ListViewTable) {
actor = ((ListView.ListViewTable) actor).getListView().getScrollPane();
}
boolean value = Boolean.parseBoolean(rawAttributeData);
if (value) {
// Add scroll focus capture listeners
actor.addListener(new ScrollFocusCaptureInputListener());
} else {
// Remove scroll focus capture listener
Iterator<EventListener> iterator = actor.getListeners().iterator();
while (iterator.hasNext()) {
EventListener listener = iterator.next();
if (listener instanceof ScrollFocusCaptureInputListener) {
iterator.remove();
}
}
}
}
示例12: FlopsyScreen
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
public FlopsyScreen(FlopsyDroidGame game, OnGlobalListener listener) {
mStage = new Stage();
mGlobalListener = listener;
game.getAssetManager().load("flopsy.sprites", TextureAtlas.class);
game.getAssetManager().finishLoading();
mTextureAtlas = game.getAssetManager().get("flopsy.sprites", TextureAtlas.class);
mLabelStyle = new Label.LabelStyle();
mLabelStyle.font = new BitmapFont(Gdx.files.internal("flappyfont.fnt"),
Gdx.files.internal("flappyfont.png"), false);
mStage.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
if(event.getTarget().equals(mAndy)) {
mGround.onDroidCollision();
return true;
}
return false;
}
});
}
示例13: showStudio
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
public void showStudio(){
Frame.actorPanel.clear();
Scene.getRoot().clearChildren();
Scene.getCurrentScene().clear();
Camera.clearAllHud();
Camera.followActor(null);
Camera.reset();
if(selectedValueExists()){
Scene.getCurrentScene().load(getSelectedValue());
for(Actor child: Scene.getCurrentScene().getChildren()){
Frame.actorPanel.addActor(child.getName());
for(EventListener l: child.getListeners())
child.removeListener(l);
}
Scene.getRoot().addActor(Scene.getCurrentScene());
}
Frame.sceneEffectPanel.update();
}
示例14: getActors
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
@Override
public Actor[] getActors(Skin skin) {
ImageButton musicTooltip = new OwnImageButton(skin, "tooltip");
musicTooltip.addListener(new TextTooltip(
I18n.bundle.format("gui.tooltip.music", SysUtilsFactory.getSysUtils().getDefaultMusicDir()), skin));
ImageButton reloadMusic = new OwnImageButton(skin, "reload");
reloadMusic.setName("reload music");
reloadMusic.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
if (event instanceof ChangeEvent) {
EventManager.instance.post(Events.MUSIC_RELOAD_CMD);
return true;
}
return false;
}
});
reloadMusic.addListener(new TextTooltip(I18n.bundle.get("gui.music.reload"), skin));
return new Actor[] { musicTooltip, reloadMusic };
}
示例15: initialize
import com.badlogic.gdx.scenes.scene2d.EventListener; //導入依賴的package包/類
private void initialize() {
if (cursorLocation == null) {
cursor = GlobalResources.linkCursor;
} else {
cursor = new Pixmap(Gdx.files.internal(cursorLocation));
}
listeners = new DelayedRemovalArray<EventListener>();
this.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
if (event instanceof InputEvent) {
Type type = ((InputEvent) event).getType();
if (type == Type.enter) {
if (!me.isDisabled())
Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursor, 4, 0));
return true;
} else if (type == Type.exit) {
Gdx.graphics.setSystemCursor(SystemCursor.Arrow);
return true;
}
}
return false;
}
});
}