Tengo dificultades para obtener eventos que funcionen con mi Actor
en libgdx. Estoy usando versiones nocturnas.No se pueden obtener eventos que funcionen en mi libgdx Actor
Mi etapa se configura en el método de una subclase Screen
show()
:
stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
Gdx.input.setInputProcessor(stage);
TestActor actor = new TestActor();
stage.addActor(actor);
Y mi clase el actor se ve así:
class TestActor extends Actor {
private Sprite sprite;
private TextureAtlas atlas;
public TestActor() {
atlas = new TextureAtlas(Gdx.files.internal("textures/images-packed.atlas"));
sprite = atlas.createSprite("logo-96");
setTouchable(Touchable.enabled);
addListener(new InputListener() {
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
Gdx.app.debug(TestGame.TAG, "TestActor.touchDown()");
return true; // must return true for touchUp event to occur
}
public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
Gdx.app.debug(TestGame.TAG, "TestActor.touchUp()");
}
});
}
@Override
public void draw(SpriteBatch batch, float parentAlpha) {
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
batch.draw(sprite, getX(), getY());
}
}
no parecen Los eventos para disparar. Por extraño que parezca, he usado widgets UI integrados como el TextButton
y puedo hacer que esos eventos funcionen bien. ¿Alguien puede ver lo que estoy haciendo mal?
Sí! ¡Gracias! Me preguntaba si tenía algo parecido. –