mcfly soft
mcfly soft

Reputation: 11655

Gdx.input.setInputProcessor for several Screens. (LIBGDX, Conceptional)

I have:

Where and how do I set the Gdx.input.setInputProcessor for the different Screens ?

I mean when switching the screen I have to unset all listeners of the old screen and add the new ones from the new screen, so they do not overlap. I cant do this in the constructor of the screen, because it is called only ones. I could do it in the @Override.resize method of the screen, but I guess this is not the way I should do ?

Where should I do this ?

Upvotes: 0

Views: 101

Answers (1)

Morchul
Morchul

Reputation: 2037

You should call Gdx.input.setInputProcessor() in the show() method.

Because screen.show() will call everytime you call setScreen(screen);

And you don't need to remove the old one because the function Gdx.input.setInputProcessor() is simple like that:

@Override
public void setInputProcessor (InputProcessor processor) {
    this.processor = processor;
}

So it replaces the old one.

Upvotes: 1

Related Questions