Forenkler jobben til skjermer som implementerer InteractiveScreen

InteractiveScreen legger seg selv til input multiplekseren
This commit is contained in:
Kristian Knarvik 2020-04-24 22:41:23 +02:00
parent 4e44d44be7
commit 4b9eadc9f2
3 changed files with 6 additions and 6 deletions

View File

@ -55,7 +55,6 @@ public class BoardActiveScreen extends InteractiveScreen {
@Override
public void show() {
super.show();
inputMultiplexer.addProcessor(this);
resetCamera();
}

View File

@ -58,8 +58,6 @@ public class CardChoiceScreen extends InteractiveScreen implements Screen {
shapeRenderer = new ShapeRenderer();
shapeRenderer.setAutoShapeType(true);
inputMultiplexer = new InputMultiplexer();
generateCards(deck);
this.chosenCards = new ArrayList<>();
@ -70,8 +68,6 @@ public class CardChoiceScreen extends InteractiveScreen implements Screen {
confirmCards.addListener(getConfirmListener());
stage.setViewport(viewport);
inputMultiplexer.addProcessor(this);
inputMultiplexer.addProcessor(stage);
}
/**
@ -144,7 +140,6 @@ public class CardChoiceScreen extends InteractiveScreen implements Screen {
@Override
public void show() {
super.show();
Gdx.input.setInputProcessor(inputMultiplexer);
}
@Override

View File

@ -6,6 +6,12 @@ import com.badlogic.gdx.InputProcessor;
* This class overrides all InputProcessor methods to make cleaner abstract screens with input processors
*/
public abstract class InteractiveScreen extends AbstractScreen implements InputProcessor {
@Override
public void show() {
super.show();
inputMultiplexer.addProcessor(this);
}
@Override
public boolean keyDown(int i) {
return false;