Commit 96925c6e authored by Fjen Undso's avatar Fjen Undso
Browse files

gameoverscreen: fix font size and button placement. fixes #15

parent 3d505edb
......@@ -24,17 +24,18 @@ public class GameOverScreen implements Screen {
Sprite bg;
int p1 = 0;
int p2 = 0;
Sprite close;
Sprite closeTop, closeBottom;
float wHeight;
float wWidth;
GlyphLayout glyphLayout = new GlyphLayout();
public GameOverScreen(int p1Score,int p2Score) {
p1 = p1Score;
p2 = p2Score;
wWidth = FrozenNumbersGame.viewport.getWorldWidth();
wHeight = FrozenNumbersGame.viewport.getWorldHeight();
game = FrozenNumbersGame.game;
m_Screens = FrozenNumbersGame.m_Screens;
......@@ -45,10 +46,14 @@ public class GameOverScreen implements Screen {
bg.setScale(scaleX, scaleY);
bg.setCenter(wWidth / 2.0f, wHeight / 2.0f);
//generating Close button#
close = new Sprite(FrozenNumbersGame.assets.get("sprites/btn_back.png", Texture.class));
close.setScale(scaleX, scaleY);
close.setCenter(wWidth / 2.0f, wHeight / 2.0f);
//generating Close button
closeBottom = new Sprite(FrozenNumbersGame.assets.get("sprites/btn_back.png", Texture.class));
closeBottom.setScale(scaleX, scaleY);
closeBottom.setCenter(wWidth / 4.0f, wHeight / 2.0f);
closeTop = new Sprite(FrozenNumbersGame.assets.get("sprites/btn_back.png", Texture.class));
closeTop.setScale(scaleX, scaleY);
closeTop.rotate(180);
closeTop.setCenter(wWidth / 4.0f * 3.0f, wHeight / 2.0f);
}
@Override
......@@ -62,12 +67,13 @@ public class GameOverScreen implements Screen {
Vector2 touchPoint = new Vector2();
FrozenNumbersGame.viewport.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY()));
//Clicking Close Button
if(close.getBoundingRectangle().contains(touchPoint.x, touchPoint.y)) {
if(closeBottom.getBoundingRectangle().contains(touchPoint.x, touchPoint.y) ||
closeTop.getBoundingRectangle().contains(touchPoint.x, touchPoint.y)) {
game.setScreen(m_Screens.get("MainMenu"));
}
}
//drawing stuff
// Drawing Stuff
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
......@@ -76,7 +82,8 @@ public class GameOverScreen implements Screen {
batch.setProjectionMatrix(FrozenNumbersGame.viewport.getCamera().combined);
batch.begin();
bg.draw(batch);
close.draw(batch);
closeBottom.draw(batch);
closeTop.draw(batch);
String p1String = new String();
String p2String = new String();
......@@ -96,30 +103,34 @@ public class GameOverScreen implements Screen {
p2String = "DRAW";
}
GlyphLayout glyphLayout = new GlyphLayout();
float w = 0;
glyphLayout.setText(FrozenNumbersGame.assets.get("size20.ttf", BitmapFont.class),String.valueOf(p1));
w = glyphLayout.width;
FrozenNumbersGame.assets.get("size20.ttf", BitmapFont.class).draw(batch, glyphLayout, (wWidth - w)/2, (float)(wHeight/4.0));
glyphLayout.setText(FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class),p1String);
w = glyphLayout.width;
FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class).draw(batch, glyphLayout, (wWidth - w)/2, (float)(wHeight/4.0 - 50));
Label p2TextLabel = new Label(p2String, new Label.LabelStyle(FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class), Color.WHITE));
// Draw Players Results
Table container = new Table();
container.setTransform(true);
container.add(p2TextLabel);
container.setRotation(180);
container.setPosition((float) (wWidth / 2.0), (float) (wHeight / 2.0 + (wHeight/4.0) + 60));
Label winLoose = new Label(null, new Label.LabelStyle(FrozenNumbersGame.assets.get("size60.ttf", BitmapFont.class), Color.WHITE));
Label points = new Label(null, new Label.LabelStyle(FrozenNumbersGame.assets.get("size40.ttf", BitmapFont.class), Color.WHITE));
// Bottom Player
winLoose.setText(p1String);
container.add(winLoose);
container.setPosition((wWidth / 2), wHeight / 4 + 30);
container.draw(batch, 1);
points.setText(p1 + " Points");
container.clearChildren();
container.add(points);
container.setPosition((wWidth / 2), wHeight / 4 - 30);
container.draw(batch, 1);
Label p2ScoreLabel = new Label(String.valueOf(p2), new Label.LabelStyle(FrozenNumbersGame.assets.get("size20.ttf", BitmapFont.class), Color.WHITE));
container = new Table();
// Top Player
container.setTransform(true);
container.add(p2ScoreLabel);
container.setRotation(180);
container.setPosition((float) (wWidth / 2.0), (float) (wHeight / 2.0 + (wHeight/4.0)));
winLoose.setText(p2String);
container.clearChildren();
container.add(winLoose);
container.setPosition((wWidth / 2), wHeight / 4 * 3 - 30);
container.draw(batch, 1);
points.setText(p2 + " Points");
container.clearChildren();
container.add(points);
container.setPosition((wWidth / 2), wHeight / 4 * 3 + 30);
container.draw(batch, 1);
batch.end();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment