I am trying to implement a map of the universe. When mouse on a pic of the planet simply hovering on the picture, I want to see some information. How to handle this in libgdx? In the following example, I am trying to give mouseClick sound while hovering, still does not work.
ImageButton imageButton = new ImageButton(drawable);
imageButton.setSize(100,100);
imageButton.setPosition(100,100);
imageButton.addListener(new FocusListener() {
@Override
public boolean handle(Event event) {
mouseClick.play();
return true;
}
});
Here how my override methods @enter and @exit looks`, I created HoverListener and override both methods.
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
super.enter(event, x, y, pointer, fromActor);
fromActor.setName("Hello");
}
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
super.exit(event, x, y, pointer, toActor);
toActor.setName("Bye");
}
Then btn_station.addListener(new HoverListener());
Still no interaction :/
Check the following:
Gdx.input.setInputProcessor(stage)
Actor
is on the stage: stage.addActor(actor)
actor.setSize(100f, 100f)
As per your response to my comments, it sounds like in this case you did not set the stage as the input processor.