Scene2d Stage Actor setup issues
I am creating a game using libgdx.
In the same each level has a class. I have stage as a member variable of the class. To this stage, I add actors.
Inside the levels class, I have attaced the input processor to the stage like below.
stage = new Stage();
sviewPort = new StretchViewport(OSR_Constants.VIEWPORT_WIDTH, OSR_Constants.VIEWPORT_HEIGHT);
OrthographicCamera camera = new OrthographicCamera(OSR_Constants.VIEWPORT_WIDTH, OSR_Constants.VIEWPORT_HEIGHT);
camera.position.set(0, 0, 0);
camera.update();
sviewPort.setCamera(camera);
stage.setViewport(sviewPort);
Gdx.input.setInputProcessor(stage);
The level object is instantiated in another class known as GameScreen. GameScreen implements the Screen interface.
I am unable to detect touch events on my actors in the stage. Each actor has also been given bounds as per the world coordinates. I have added the following code on each actor to detect touch
this.addListener(new InputListener(){
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
System.out.println("touchdown at " + x + " " + y);
return true;
}
});