Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MilderJoghurt
FrozenNumbers
Commits
96925c6e
Commit
96925c6e
authored
Jan 08, 2016
by
Fjen Undso
Browse files
gameoverscreen: fix font size and button placement. fixes
#15
parent
3d505edb
Changes
1
Hide whitespace changes
Inline
Side-by-side
core/src/org/milderjoghurt/frozennumbers/screens/GameOverScreen.java
View file @
96925c6e
...
...
@@ -24,17 +24,18 @@ public class GameOverScreen implements Screen {
Sprite
bg
;
int
p1
=
0
;
int
p2
=
0
;
Sprite
close
;
Sprite
close
Top
,
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"
));
}
}
//
d
rawing
s
tuff
//
D
rawing
S
tuff
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
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment