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 @Override
public void show() { public void show() {
super.show(); super.show();
inputMultiplexer.addProcessor(this);
resetCamera(); resetCamera();
} }

View File

@ -58,8 +58,6 @@ public class CardChoiceScreen extends InteractiveScreen implements Screen {
shapeRenderer = new ShapeRenderer(); shapeRenderer = new ShapeRenderer();
shapeRenderer.setAutoShapeType(true); shapeRenderer.setAutoShapeType(true);
inputMultiplexer = new InputMultiplexer();
generateCards(deck); generateCards(deck);
this.chosenCards = new ArrayList<>(); this.chosenCards = new ArrayList<>();
@ -70,8 +68,6 @@ public class CardChoiceScreen extends InteractiveScreen implements Screen {
confirmCards.addListener(getConfirmListener()); confirmCards.addListener(getConfirmListener());
stage.setViewport(viewport); stage.setViewport(viewport);
inputMultiplexer.addProcessor(this);
inputMultiplexer.addProcessor(stage);
} }
/** /**
@ -144,7 +140,6 @@ public class CardChoiceScreen extends InteractiveScreen implements Screen {
@Override @Override
public void show() { public void show() {
super.show(); super.show();
Gdx.input.setInputProcessor(inputMultiplexer);
} }
@Override @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 * This class overrides all InputProcessor methods to make cleaner abstract screens with input processors
*/ */
public abstract class InteractiveScreen extends AbstractScreen implements InputProcessor { public abstract class InteractiveScreen extends AbstractScreen implements InputProcessor {
@Override
public void show() {
super.show();
inputMultiplexer.addProcessor(this);
}
@Override @Override
public boolean keyDown(int i) { public boolean keyDown(int i) {
return false; return false;