com.badlogic.gdx.scenes.scene2d.Event Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.Event. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DropDownSetting.java    From Cubes with MIT License 6 votes vote down vote up
@Override
public Actor getActor(final String settingName, VisualSettingManager visualSettingManager) {
  final SelectBox<String> selectBox = new SelectBox<String>(visualSettingManager.getSkin()) {
    @Override
    protected String toString(String s) {
      return Settings.getLocalisedSettingName(settingName + "." + s);
    }
  };
  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;
}
 
Example #2
Source File: ServerRunningMenu.java    From Cubes with MIT License 6 votes vote down vote up
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;
    }
  });
}
 
Example #3
Source File: FlopsyScreen.java    From flopsydroid with Apache License 2.0 6 votes vote down vote up
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;
        }
    });
}
 
Example #4
Source File: DelegateInputEventsLmlAttribute.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@Override
public void process(final LmlParser parser, LmlTag tag, final Actor actor, String rawAttributeData) {
    final String id = parser.parseString(rawAttributeData);
    // Post for one frame to let the layout to be fully parsed (target actor may be parsed after this attribute).
    actor.addAction(Actions.run(new Runnable() {
        @Override
        public void run() {
            final Actor targetActor = parser.getActorsMappedByIds().get(id);
            if (targetActor == null) {
                parser.throwErrorIfStrict("Cannot find actor for ID: " + id);
                return;
            }

            actor.addListener(new EventListener() {
                @Override
                public boolean handle(Event event) {
                    if (event instanceof InputEvent) {
                        return targetActor.notify(event, false);
                    }
                    return false;
                }
            });
        }
    }));
}
 
Example #5
Source File: DialogCustomProperty.java    From skin-composer with MIT License 5 votes vote down vote up
@Override
public boolean handle(Event event) {
    if (event instanceof CustomPropertyEvent) {
        CustomPropertyEvent newPropertyEvent = (CustomPropertyEvent) event;
        if (newPropertyEvent.result) {
            newPropertyEntered(newPropertyEvent.propertyName, newPropertyEvent.propertyType);
        } else {
            cancelled();
        }
    }
    return false;
}
 
Example #6
Source File: StringSetting.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public Actor getActor(String settingName, VisualSettingManager visualSettingManager) {
  final TextField textField = new TextField(s, visualSettingManager.getSkin());
  textField.addListener(new EventListener() {
    @Override
    public boolean handle(Event event) {
      if (!(event instanceof SettingsMenu.SaveEvent)) return false;
      set(textField.getText());
      return true;
    }
  });
  return textField;
}
 
Example #7
Source File: ClientErrorMenu.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public void render() {
  super.render();
  if (!firstRender) return;
  addButtonListener(new EventListener() {
    @Override
    public boolean handle(Event event) {
      if (!(event instanceof ChangeListener.ChangeEvent)) return false;
      Adapter.setMenu(new MainMenu());
      return true;
    }
  });
  firstRender = false;
}
 
Example #8
Source File: IconTextButton.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public IconTextButton(Button.ButtonStyle style, String text, FontTBL.BitmapFont font) {
  add(button = new Button(style)).fill(false).pad(2).padLeft(1).padTop(3);
  add(label = new LabelButton(text, font)).grow().spaceLeft(25).row();
  setTouchable(Touchable.enabled);
  addListener(new InputListener() {
    @Override
    public boolean handle(Event e) {
      button.getClickListener().handle(e);
      label.clickListener.handle(e);
      return true;
    }
  });
}
 
Example #9
Source File: GdxHelper.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static void showStageEvents(final Stage stage) {
    EventListener listener = new EventListener() {
        private final Vector2 tmp = new Vector2();
        private Actor actor = new Actor() {
            @Override public void draw(Batch batch, float parentAlpha) {
                if (target == null)
                    return;
                batch.end();
                Config.shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
                Config.shapeRenderer.setProjectionMatrix(stage.getCamera().combined);
                Gdx.gl.glLineWidth(6);
                Config.shapeRenderer.setColor(Color.ORANGE);
                Vector2 pos = target.localToStageCoordinates(tmp.set(0, 0));
                float x = pos.x, y = pos.y;
                Vector2 top = target.localToStageCoordinates(tmp.set(target.getWidth(), target.getHeight()));
                float maxX = top.x, maxY = top.y;
                Config.shapeRenderer.rect(x, y, maxX - x, maxY - y);

                Config.shapeRenderer.end();
                batch.begin();
            }
        };

        {
            stage.addActor(actor);
        }

        public Actor target;

        @Override public boolean handle(Event event) {
            target = event.getTarget();
            return false;
        }
    };
    stage.addListener(listener);
}
 
Example #10
Source File: WindowListener.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public final boolean handle(Event event) {
    if (event instanceof WindowEvent) {
        WindowEvent windowEvent = (WindowEvent) event;
        return notify(windowEvent);
    }
    return false;
}
 
Example #11
Source File: ResizeListener.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public boolean handle(Event event) {
    if (event instanceof ResizeEvent) {
        resize();
        return true;
    }
    return false;
}
 
Example #12
Source File: AnimationListener.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public boolean handle(Event event) {
    if (event instanceof AnimationEvent) {
        onAnimationEvent((AnimationEvent) event);
        return true;
    }
    return false;
}
 
Example #13
Source File: RefreshListener.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public final boolean handle(Event event) {
    if (event == RefreshEvent.INSTANCE) {
        refreshed();
        return true;
    }
    return false;
}
 
Example #14
Source File: IngredientWindow.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public boolean handle(Event event) {
    if (event instanceof Bought) {
        bought();
        return true;
    }
    return false;
}
 
Example #15
Source File: StageResizeListener.java    From skin-composer with MIT License 5 votes vote down vote up
@Override
public boolean handle(Event event) {
    if (event instanceof StageResizeEvent) {
        StageResizeEvent sEvent = (StageResizeEvent) event;
        resized(sEvent.getWidth(), sEvent.getHeight());
    }
    
    return false;
}
 
Example #16
Source File: DialogTenPatchSettings.java    From skin-composer with MIT License 5 votes vote down vote up
@Override
public boolean handle(Event event) {
    if (event instanceof DialogTenPatchSettingsEvent) {
        settingsUpdated((DialogTenPatchSettingsEvent) event);
    }
    return false;
}
 
Example #17
Source File: DialogListener.java    From skin-composer with MIT License 5 votes vote down vote up
@Override
default boolean handle(Event event) {
    if (event instanceof DialogEvent) {
        var dialogEvent = (DialogEvent) event;
        if (dialogEvent.type == DialogEvent.Type.OPEN) {
            opened();
        } else if (dialogEvent.type == DialogEvent.Type.CLOSE) {
            closed();
        }
        
        return true;
    }
    
    return false;
}
 
Example #18
Source File: GameWindow.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
@Override public boolean notify(Event event, boolean capture) {
    return super.notify(event, capture);
}
 
Example #19
Source File: DiePaneListener.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
@Override public boolean handle(Event event) {
    return event instanceof PaneEvent && notify((PaneEvent) event);
}
 
Example #20
Source File: TimeThresholdChangeListener.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
@Override
public boolean handle(Event event) {
    return changeListener.handle(event) || focusListener.handle(event);
}
 
Example #21
Source File: WindowResizeListener.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
@Override
public boolean handle (Event event) {
	if (event instanceof WindowResizeEvent == false) return false;
	resize();
	return false;
}
 
Example #22
Source File: CraftingPane.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
@Override public boolean handle(Event event) {
    if (event instanceof IngredientReplaced) {
        onIngredientReplaced(((IngredientReplaced) event).icon.item);
    }
    return false;
}