Endrer variabelnavn og legger til kommentarer

This commit is contained in:
Kristian Knarvik 2020-04-07 15:11:07 +02:00
parent 136235d86b
commit 13255218f0

View File

@ -29,15 +29,23 @@ public class IPAddressScreen extends AbstractScreen {
private final Stage stage; private final Stage stage;
private TextField txtinput; private TextField txtinput;
/**
* Instantiates a new ip address screen
* @param roboRallyWrapper The Robo Rally wrapper which is parent of this screen
*/
public IPAddressScreen(final RoboRallyWrapper roboRallyWrapper) { public IPAddressScreen(final RoboRallyWrapper roboRallyWrapper) {
stage = new Stage(); stage = new Stage();
Skin skin = new Skin(Gdx.files.internal("uiskin.json")); Skin skin = new Skin(Gdx.files.internal("uiskin.json"));
TextButton loginbutton = new TextButton("click", skin); TextButton joinButton = new TextButton("Join", skin);
loginbutton.setSize(300,60); joinButton.setSize(300,60);
loginbutton.setPosition(300,300); joinButton.setPosition(300,300);
loginbutton.addListener(new ClickListener(){ joinButton.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent e, float x, float y, int point, int button) {
return true;
}
@Override @Override
public void touchUp(InputEvent e, float x, float y, int point, int button) { public void touchUp(InputEvent e, float x, float y, int point, int button) {
try { try {
@ -54,14 +62,13 @@ public class IPAddressScreen extends AbstractScreen {
txtinput.setPosition(300,250); txtinput.setPosition(300,250);
txtinput.setSize(150,40); txtinput.setSize(150,40);
stage.addActor(txtinput); stage.addActor(txtinput);
stage.addActor(loginbutton); stage.addActor(joinButton);
camera = new OrthographicCamera(); camera = new OrthographicCamera();
viewport = new FitViewport(applicationWidth, applicationHeight, camera); viewport = new FitViewport(applicationWidth, applicationHeight, camera);
this.roboRallyWrapper = roboRallyWrapper; this.roboRallyWrapper = roboRallyWrapper;
camera.setToOrtho(false, applicationWidth, applicationHeight); camera.setToOrtho(false, applicationWidth, applicationHeight);
Gdx.input.setInputProcessor(stage); Gdx.input.setInputProcessor(stage);
} }
@ -74,10 +81,10 @@ public class IPAddressScreen extends AbstractScreen {
roboRallyWrapper.batch.begin(); roboRallyWrapper.batch.begin();
roboRallyWrapper.font.draw(roboRallyWrapper.batch, "Enter IP address and click the button to join a server", roboRallyWrapper.font.draw(roboRallyWrapper.batch, "Enter IP address and click the button to join a server",
applicationWidth / 2f - 380 / 2f,applicationHeight / 2f + 100,380, 1, true); applicationWidth / 2f - 380 / 2f,applicationHeight / 2f + 100,380, 1,
true);
roboRallyWrapper.batch.end(); roboRallyWrapper.batch.end();
stage.draw(); stage.draw();
} }
@Override @Override