use of com.badlogic.gdx.scenes.scene2d.EventListener in project Catacomb-Snatch by Catacomb-Snatch.
the class MenuScene method init.
protected void init() {
// Set actor width
for (Actor actor : getActors()) {
actor.setWidth(150);
actor.addListener(new EventListener() {
@Override
public boolean handle(Event event) {
aniY = (int) event.getListenerActor().getY();
return true;
}
});
}
// Set index to the topmost actor
index = getActors().size - 1;
// Properly place actors
update(true);
}
use of com.badlogic.gdx.scenes.scene2d.EventListener in project Catacomb-Snatch by Catacomb-Snatch.
the class Scene method tick.
@Override
public void tick(float delta) {
// Draw background
if (drawBackground && background != null) {
getBatch().begin();
getBatch().setColor(backgroundColor);
getBatch().draw(background, 0, 0, Screen.getWidth(), Screen.getHeight());
getBatch().end();
}
// Updating mouse dependent stuff in render()
if (!Gdx.input.isTouched()) {
mousePos = screenToStageCoordinates(mousePos.set(Gdx.input.getX(), Gdx.input.getY()));
for (Actor a : getActors()) {
currentActorRect.set(a.getX(), a.getY(), a.getWidth(), a.getHeight());
for (EventListener el : a.getListeners()) {
if (!(el instanceof InputListener))
continue;
InputListener il = (InputListener) el;
if (currentActorRect.contains(mousePos.x, mousePos.y)) {
il.enter(null, mousePos.x, mousePos.y, -1, null);
} else {
il.exit(null, mousePos.x, mousePos.y, -1, null);
}
}
}
}
super.draw();
getBatch().begin();
}
Aggregations