2
\$\begingroup\$

I want to use scene2D, in libGDX, to detect click on object.

I have this simple Game sample :

Stage stage; @Override public void create() { this.stage = new Stage(1280, 720, true); MyActor actor = new MyActor(); Gdx.input.setInputProcessor(stage); actor.setTexture(new TextureRegion(new Texture(Gdx.files.internal("plateau.jpg")))); actor.setScale(0.1f); stage.addActor(actor); actor.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { System.out.println("down"+Math.random()); return true; } }); } @Override public void render() { stage.act(); stage.draw(); } 

MyActor is a simple class extending Actor with a rendertexture. The Event is working fine at start. But when resizing the frame, while the Actor is streched as wanted, the coordinates of the click are not updated and thus misplaced.

How to make the stage using the new size of the items as base to the event ?

Thanks.

\$\endgroup\$

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.