Add a horizontal band on the pause menu
This commit is contained in:
parent
daef6d047e
commit
9eaba524bd
8 changed files with 309 additions and 24 deletions
|
@ -1,90 +1,265 @@
|
|||
info face="GeosansLight" size=64 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=-2,-2
|
||||
common lineHeight=77 base=58 scaleW=512 scaleH=512 pages=1 packed=0
|
||||
page id=0 file="geosans-light.png"
|
||||
chars count=12
|
||||
chars count=24
|
||||
char id=10 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=0 page=0 chnl=0
|
||||
char id=32 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=57 xadvance=16 page=0 chnl=0
|
||||
char id=48 x=0 y=0 width=36 height=51 xoffset=0 yoffset=9 xadvance=35 page=0 chnl=0
|
||||
char id=49 x=297 y=0 width=13 height=48 xoffset=10 yoffset=11 xadvance=35 page=0 chnl=0
|
||||
char id=50 x=94 y=0 width=31 height=49 xoffset=2 yoffset=10 xadvance=35 page=0 chnl=0
|
||||
char id=49 x=318 y=0 width=13 height=48 xoffset=10 yoffset=11 xadvance=35 page=0 chnl=0
|
||||
char id=50 x=287 y=0 width=31 height=49 xoffset=2 yoffset=10 xadvance=35 page=0 chnl=0
|
||||
char id=51 x=36 y=0 width=29 height=50 xoffset=3 yoffset=10 xadvance=35 page=0 chnl=0
|
||||
char id=52 x=125 y=0 width=34 height=49 xoffset=1 yoffset=10 xadvance=35 page=0 chnl=0
|
||||
char id=53 x=159 y=0 width=34 height=49 xoffset=0 yoffset=11 xadvance=35 page=0 chnl=0
|
||||
char id=54 x=193 y=0 width=34 height=49 xoffset=1 yoffset=11 xadvance=35 page=0 chnl=0
|
||||
char id=55 x=227 y=0 width=36 height=49 xoffset=0 yoffset=11 xadvance=35 page=0 chnl=0
|
||||
char id=56 x=65 y=0 width=29 height=50 xoffset=3 yoffset=10 xadvance=35 page=0 chnl=0
|
||||
char id=57 x=263 y=0 width=34 height=49 xoffset=1 yoffset=11 xadvance=35 page=0 chnl=0
|
||||
kernings count=73
|
||||
kerning first=49 second=48 amount=-7
|
||||
char id=52 x=253 y=0 width=34 height=49 xoffset=1 yoffset=10 xadvance=35 page=0 chnl=0
|
||||
char id=53 x=115 y=0 width=34 height=49 xoffset=0 yoffset=11 xadvance=35 page=0 chnl=0
|
||||
char id=54 x=149 y=0 width=34 height=49 xoffset=1 yoffset=11 xadvance=35 page=0 chnl=0
|
||||
char id=55 x=217 y=0 width=36 height=49 xoffset=0 yoffset=11 xadvance=35 page=0 chnl=0
|
||||
char id=56 x=86 y=0 width=29 height=50 xoffset=3 yoffset=10 xadvance=35 page=0 chnl=0
|
||||
char id=57 x=183 y=0 width=34 height=49 xoffset=1 yoffset=11 xadvance=35 page=0 chnl=0
|
||||
char id=97 x=403 y=0 width=29 height=30 xoffset=1 yoffset=30 xadvance=33 page=0 chnl=0
|
||||
char id=101 x=454 y=0 width=30 height=30 xoffset=1 yoffset=30 xadvance=31 page=0 chnl=0
|
||||
char id=102 x=70 y=0 width=16 height=50 xoffset=2 yoffset=9 xadvance=18 page=0 chnl=0
|
||||
char id=108 x=65 y=0 width=5 height=50 xoffset=4 yoffset=9 xadvance=12 page=0 chnl=0
|
||||
char id=109 x=28 y=51 width=35 height=29 xoffset=3 yoffset=30 xadvance=41 page=0 chnl=0
|
||||
char id=110 x=63 y=51 width=23 height=29 xoffset=3 yoffset=30 xadvance=29 page=0 chnl=0
|
||||
char id=111 x=374 y=0 width=29 height=30 xoffset=1 yoffset=30 xadvance=31 page=0 chnl=0
|
||||
char id=112 x=331 y=0 width=29 height=41 xoffset=3 yoffset=30 xadvance=33 page=0 chnl=0
|
||||
char id=115 x=484 y=0 width=20 height=30 xoffset=1 yoffset=30 xadvance=21 page=0 chnl=0
|
||||
char id=116 x=360 y=0 width=14 height=40 xoffset=1 yoffset=19 xadvance=16 page=0 chnl=0
|
||||
char id=117 x=432 y=0 width=22 height=30 xoffset=3 yoffset=30 xadvance=27 page=0 chnl=0
|
||||
char id=118 x=0 y=51 width=28 height=30 xoffset=0 yoffset=30 xadvance=28 page=0 chnl=0
|
||||
kernings count=236
|
||||
kerning first=56 second=102 amount=-2
|
||||
kerning first=50 second=111 amount=-3
|
||||
kerning first=51 second=115 amount=-3
|
||||
kerning first=48 second=49 amount=-11
|
||||
kerning first=117 second=52 amount=-3
|
||||
kerning first=110 second=118 amount=-4
|
||||
kerning first=56 second=52 amount=-2
|
||||
kerning first=109 second=49 amount=-15
|
||||
kerning first=57 second=53 amount=-3
|
||||
kerning first=118 second=50 amount=-9
|
||||
kerning first=118 second=53 amount=-5
|
||||
kerning first=57 second=111 amount=-3
|
||||
kerning first=55 second=108 amount=-3
|
||||
kerning first=52 second=102 amount=-3
|
||||
kerning first=102 second=102 amount=-2
|
||||
kerning first=55 second=57 amount=-4
|
||||
kerning first=116 second=51 amount=-7
|
||||
kerning first=55 second=115 amount=-13
|
||||
kerning first=57 second=50 amount=-2
|
||||
kerning first=48 second=52 amount=-4
|
||||
kerning first=51 second=49 amount=-12
|
||||
kerning first=112 second=57 amount=-2
|
||||
kerning first=55 second=102 amount=-2
|
||||
kerning first=56 second=116 amount=-1
|
||||
kerning first=101 second=101 amount=2
|
||||
kerning first=112 second=49 amount=-12
|
||||
kerning first=49 second=118 amount=-8
|
||||
kerning first=108 second=112 amount=-3
|
||||
kerning first=55 second=118 amount=-9
|
||||
kerning first=102 second=51 amount=-5
|
||||
kerning first=50 second=109 amount=-4
|
||||
kerning first=115 second=50 amount=-2
|
||||
kerning first=118 second=56 amount=-2
|
||||
kerning first=101 second=49 amount=-14
|
||||
kerning first=49 second=115 amount=-8
|
||||
kerning first=109 second=110 amount=-3
|
||||
kerning first=101 second=53 amount=-2
|
||||
kerning first=50 second=97 amount=-3
|
||||
kerning first=57 second=56 amount=-3
|
||||
kerning first=118 second=55 amount=-6
|
||||
kerning first=56 second=50 amount=-4
|
||||
kerning first=51 second=110 amount=-4
|
||||
kerning first=54 second=49 amount=-13
|
||||
kerning first=55 second=51 amount=-6
|
||||
kerning first=48 second=55 amount=-3
|
||||
kerning first=50 second=112 amount=-4
|
||||
kerning first=110 second=108 amount=-4
|
||||
kerning first=54 second=50 amount=-6
|
||||
kerning first=56 second=112 amount=-3
|
||||
kerning first=112 second=50 amount=-5
|
||||
kerning first=50 second=116 amount=-3
|
||||
kerning first=115 second=49 amount=-13
|
||||
kerning first=108 second=109 amount=-3
|
||||
kerning first=52 second=51 amount=-4
|
||||
kerning first=52 second=50 amount=-3
|
||||
kerning first=49 second=108 amount=-10
|
||||
kerning first=51 second=50 amount=-4
|
||||
kerning first=50 second=50 amount=-2
|
||||
kerning first=49 second=109 amount=-9
|
||||
kerning first=50 second=115 amount=-4
|
||||
kerning first=55 second=116 amount=-5
|
||||
kerning first=57 second=49 amount=-11
|
||||
kerning first=116 second=50 amount=-6
|
||||
kerning first=54 second=52 amount=-4
|
||||
kerning first=101 second=118 amount=-4
|
||||
kerning first=110 second=56 amount=-3
|
||||
kerning first=49 second=101 amount=-8
|
||||
kerning first=110 second=109 amount=-3
|
||||
kerning first=110 second=51 amount=-3
|
||||
kerning first=118 second=49 amount=-13
|
||||
kerning first=55 second=50 amount=-6
|
||||
kerning first=109 second=53 amount=-4
|
||||
kerning first=49 second=56 amount=-10
|
||||
kerning first=102 second=50 amount=-6
|
||||
kerning first=101 second=52 amount=-2
|
||||
kerning first=102 second=108 amount=-2
|
||||
kerning first=57 second=52 amount=-6
|
||||
kerning first=50 second=54 amount=-3
|
||||
kerning first=51 second=118 amount=-2
|
||||
kerning first=117 second=55 amount=-3
|
||||
kerning first=116 second=55 amount=-3
|
||||
kerning first=51 second=53 amount=-4
|
||||
kerning first=49 second=49 amount=-17
|
||||
kerning first=102 second=101 amount=-3
|
||||
kerning first=57 second=51 amount=-2
|
||||
kerning first=52 second=50 amount=-3
|
||||
kerning first=55 second=56 amount=-4
|
||||
kerning first=110 second=49 amount=-15
|
||||
kerning first=108 second=108 amount=-4
|
||||
kerning first=50 second=55 amount=-3
|
||||
kerning first=55 second=48 amount=-3
|
||||
kerning first=56 second=53 amount=-4
|
||||
kerning first=55 second=109 amount=-10
|
||||
kerning first=102 second=56 amount=-3
|
||||
kerning first=118 second=51 amount=-7
|
||||
kerning first=111 second=55 amount=-4
|
||||
kerning first=109 second=52 amount=-4
|
||||
kerning first=108 second=55 amount=-3
|
||||
kerning first=49 second=110 amount=-9
|
||||
kerning first=117 second=53 amount=-4
|
||||
kerning first=55 second=101 amount=-13
|
||||
kerning first=53 second=55 amount=-2
|
||||
kerning first=49 second=102 amount=-8
|
||||
kerning first=50 second=108 amount=-4
|
||||
kerning first=110 second=57 amount=-2
|
||||
kerning first=115 second=51 amount=-4
|
||||
kerning first=110 second=50 amount=-2
|
||||
kerning first=52 second=57 amount=-4
|
||||
kerning first=102 second=116 amount=-2
|
||||
kerning first=49 second=117 amount=-9
|
||||
kerning first=116 second=56 amount=-2
|
||||
kerning first=110 second=102 amount=-4
|
||||
kerning first=51 second=52 amount=-3
|
||||
kerning first=112 second=51 amount=-4
|
||||
kerning first=108 second=56 amount=-4
|
||||
kerning first=102 second=49 amount=-7
|
||||
kerning first=50 second=53 amount=-4
|
||||
kerning first=49 second=55 amount=-9
|
||||
kerning first=53 second=50 amount=-7
|
||||
kerning first=55 second=52 amount=-20
|
||||
kerning first=56 second=118 amount=-2
|
||||
kerning first=110 second=52 amount=-4
|
||||
kerning first=49 second=97 amount=-8
|
||||
kerning first=56 second=108 amount=-4
|
||||
kerning first=55 second=49 amount=-9
|
||||
kerning first=51 second=112 amount=-3
|
||||
kerning first=53 second=52 amount=-2
|
||||
kerning first=111 second=53 amount=-3
|
||||
kerning first=110 second=110 amount=-3
|
||||
kerning first=111 second=111 amount=3
|
||||
kerning first=54 second=51 amount=-2
|
||||
kerning first=49 second=54 amount=-8
|
||||
kerning first=116 second=49 amount=-13
|
||||
kerning first=109 second=57 amount=-2
|
||||
kerning first=111 second=50 amount=-5
|
||||
kerning first=50 second=56 amount=-2
|
||||
kerning first=102 second=52 amount=-6
|
||||
kerning first=49 second=116 amount=-8
|
||||
kerning first=53 second=53 amount=-3
|
||||
kerning first=55 second=117 amount=-10
|
||||
kerning first=109 second=102 amount=-3
|
||||
kerning first=51 second=109 amount=-4
|
||||
kerning first=51 second=51 amount=-4
|
||||
kerning first=50 second=50 amount=-2
|
||||
kerning first=109 second=118 amount=-3
|
||||
kerning first=50 second=117 amount=-2
|
||||
kerning first=48 second=51 amount=-2
|
||||
kerning first=97 second=50 amount=-1
|
||||
kerning first=117 second=108 amount=-3
|
||||
kerning first=55 second=110 amount=-10
|
||||
kerning first=51 second=102 amount=-3
|
||||
kerning first=51 second=57 amount=-3
|
||||
kerning first=108 second=49 amount=-9
|
||||
kerning first=109 second=51 amount=-3
|
||||
kerning first=108 second=50 amount=-3
|
||||
kerning first=118 second=52 amount=-5
|
||||
kerning first=108 second=53 amount=-4
|
||||
kerning first=49 second=52 amount=-11
|
||||
kerning first=117 second=51 amount=-3
|
||||
kerning first=49 second=48 amount=-7
|
||||
kerning first=108 second=117 amount=-3
|
||||
kerning first=110 second=53 amount=-4
|
||||
kerning first=97 second=49 amount=-14
|
||||
kerning first=101 second=57 amount=-2
|
||||
kerning first=50 second=110 amount=-4
|
||||
kerning first=115 second=57 amount=-3
|
||||
kerning first=97 second=53 amount=-3
|
||||
kerning first=52 second=55 amount=-4
|
||||
kerning first=56 second=56 amount=-4
|
||||
kerning first=101 second=51 amount=-4
|
||||
kerning first=50 second=49 amount=-12
|
||||
kerning first=49 second=57 amount=-8
|
||||
kerning first=101 second=102 amount=-4
|
||||
kerning first=54 second=57 amount=-4
|
||||
kerning first=117 second=56 amount=-3
|
||||
kerning first=111 second=49 amount=-13
|
||||
kerning first=108 second=110 amount=-3
|
||||
kerning first=56 second=55 amount=-3
|
||||
kerning first=112 second=55 amount=-3
|
||||
kerning first=108 second=52 amount=-2
|
||||
kerning first=51 second=55 amount=-4
|
||||
kerning first=56 second=56 amount=-4
|
||||
kerning first=50 second=102 amount=-4
|
||||
kerning first=56 second=51 amount=-3
|
||||
kerning first=56 second=109 amount=-3
|
||||
kerning first=111 second=57 amount=-2
|
||||
kerning first=109 second=108 amount=-4
|
||||
kerning first=102 second=53 amount=-4
|
||||
kerning first=101 second=55 amount=-1
|
||||
kerning first=49 second=50 amount=-11
|
||||
kerning first=109 second=50 amount=-2
|
||||
kerning first=55 second=53 amount=-8
|
||||
kerning first=102 second=111 amount=-4
|
||||
kerning first=56 second=110 amount=-3
|
||||
kerning first=49 second=51 amount=-12
|
||||
kerning first=53 second=49 amount=-10
|
||||
kerning first=49 second=112 amount=-9
|
||||
kerning first=111 second=102 amount=-3
|
||||
kerning first=53 second=51 amount=-3
|
||||
kerning first=112 second=118 amount=-3
|
||||
kerning first=48 second=50 amount=-2
|
||||
kerning first=51 second=116 amount=-2
|
||||
kerning first=52 second=49 amount=-10
|
||||
kerning first=55 second=111 amount=-14
|
||||
kerning first=116 second=53 amount=-4
|
||||
kerning first=51 second=117 amount=-3
|
||||
kerning first=97 second=52 amount=-3
|
||||
kerning first=53 second=57 amount=-3
|
||||
kerning first=50 second=52 amount=-13
|
||||
kerning first=53 second=51 amount=-3
|
||||
kerning first=101 second=116 amount=-3
|
||||
kerning first=101 second=50 amount=-6
|
||||
kerning first=116 second=111 amount=-3
|
||||
kerning first=55 second=97 amount=-14
|
||||
kerning first=111 second=51 amount=-2
|
||||
kerning first=109 second=56 amount=-3
|
||||
kerning first=49 second=111 amount=-8
|
||||
kerning first=56 second=49 amount=-12
|
||||
kerning first=49 second=53 amount=-9
|
||||
kerning first=116 second=52 amount=-5
|
||||
kerning first=57 second=97 amount=-3
|
||||
kerning first=55 second=54 amount=-9
|
||||
kerning first=109 second=109 amount=-3
|
||||
kerning first=50 second=101 amount=-3
|
||||
kerning first=117 second=49 amount=-14
|
||||
kerning first=102 second=97 amount=-3
|
||||
kerning first=117 second=50 amount=-5
|
||||
kerning first=57 second=55 amount=-3
|
||||
kerning first=48 second=55 amount=-3
|
||||
kerning first=54 second=55 amount=-3
|
||||
kerning first=108 second=51 amount=-3
|
||||
kerning first=50 second=118 amount=-4
|
||||
kerning first=56 second=57 amount=-4
|
||||
kerning first=97 second=51 amount=-2
|
||||
kerning first=51 second=56 amount=-1
|
||||
kerning first=51 second=108 amount=-1
|
||||
kerning first=111 second=118 amount=-3
|
||||
kerning first=56 second=117 amount=-3
|
||||
kerning first=55 second=112 amount=-10
|
||||
kerning first=116 second=97 amount=-3
|
||||
kerning first=50 second=51 amount=-4
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 9.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 4.1 KiB |
75
core/src/io/github/lonamiwebs/klooni/actors/Band.java
Normal file
75
core/src/io/github/lonamiwebs/klooni/actors/Band.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
package io.github.lonamiwebs.klooni.actors;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
|
||||
import io.github.lonamiwebs.klooni.game.GameLayout;
|
||||
import io.github.lonamiwebs.klooni.game.Scorer;
|
||||
|
||||
// Score and pause menu band actually
|
||||
public class Band extends Actor {
|
||||
|
||||
private final Scorer scorer;
|
||||
private final ShapeRenderer shapeRenderer; // To draw the horizontal "Band"
|
||||
private final Color bandColor;
|
||||
|
||||
public final Rectangle scoreBounds;
|
||||
public final Rectangle infoBounds;
|
||||
|
||||
public final Label infoLabel;
|
||||
public final Label scoreLabel;
|
||||
|
||||
public Band(final GameLayout layout, final Scorer aScorer, final Color aBandColor) {
|
||||
scorer = aScorer;
|
||||
bandColor = aBandColor;
|
||||
shapeRenderer = new ShapeRenderer(20); // Only 20 vertex are required, maybe less
|
||||
|
||||
Label.LabelStyle scoreStyle = new Label.LabelStyle();
|
||||
scoreStyle.font = new BitmapFont(Gdx.files.internal("font/geosans-light.fnt"));
|
||||
|
||||
scoreLabel = new Label("", scoreStyle);
|
||||
scoreLabel.setAlignment(Align.center);
|
||||
infoLabel = new Label("pause menu", scoreStyle);
|
||||
infoLabel.setAlignment(Align.center);
|
||||
|
||||
scoreBounds = new Rectangle();
|
||||
infoBounds = new Rectangle();
|
||||
layout.update(this);
|
||||
}
|
||||
|
||||
public void setGameOver() {
|
||||
infoLabel.setText("no moves left");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
// We need to end (thus flush) the batch or things will mess up!
|
||||
batch.end();
|
||||
|
||||
float w = getWidth();
|
||||
float h = getHeight();
|
||||
|
||||
// TODO This is not the best way to apply the transformation, but, oh well
|
||||
float x = getParent().getX();
|
||||
float y = getParent().getY();
|
||||
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
|
||||
shapeRenderer.setColor(bandColor);
|
||||
shapeRenderer.rect(x + getX(), y + getY(), w, h);
|
||||
shapeRenderer.end();
|
||||
batch.begin();
|
||||
|
||||
scoreLabel.setBounds(x + scoreBounds.x, y + scoreBounds.y, scoreBounds.width, scoreBounds.height);
|
||||
scoreLabel.setText(Integer.toString(scorer.getCurrentScore()));
|
||||
scoreLabel.draw(batch, parentAlpha);
|
||||
|
||||
infoLabel.setBounds(x + infoBounds.x, y + infoBounds.y, infoBounds.width, infoBounds.height);
|
||||
infoLabel.draw(batch, parentAlpha);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,8 @@ package io.github.lonamiwebs.klooni.game;
|
|||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
|
||||
import io.github.lonamiwebs.klooni.actors.Band;
|
||||
|
||||
// Helper class to calculate the size of each element
|
||||
//
|
||||
// TODO In a future, perhaps this could handle landscape mode differently
|
||||
|
@ -71,4 +73,20 @@ public class GameLayout {
|
|||
marginWidth, 0f,
|
||||
availableWidth, pieceHolderHeight);
|
||||
}
|
||||
|
||||
public void update(Band band) {
|
||||
final Rectangle area = new Rectangle(
|
||||
0, pieceHolderHeight + boardHeight,
|
||||
screenWidth, scoreHeight);
|
||||
|
||||
band.setBounds(area.x, area.y, area.width, area.height);
|
||||
// Let the band have the following shape:
|
||||
// 10% (100) padding
|
||||
// 35% (90%) score label
|
||||
// 10% (55%) padding
|
||||
// 35% (45%) info label
|
||||
// 10% (10%) padding
|
||||
band.scoreBounds.set(area.x, area.y + area.height * 0.55f, area.width, area.height * 0.35f);
|
||||
band.infoBounds.set(area.x, area.y + area.height * 0.10f, area.width, area.height * 0.35f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,11 @@ public class Scorer {
|
|||
scoreStyle.font = new BitmapFont(Gdx.files.internal("font/geosans-light.fnt"));
|
||||
|
||||
currentScoreLabel = new Label("0", scoreStyle);
|
||||
currentScoreLabel.setColor(Color.GOLD);
|
||||
currentScoreLabel.setAlignment(Align.right);
|
||||
|
||||
maxScoreLabel = new Label(Integer.toString(maxScore), scoreStyle);
|
||||
maxScoreLabel.setColor(new Color(0x65D681FF));
|
||||
|
||||
layout.update(this);
|
||||
}
|
||||
|
@ -60,6 +63,10 @@ public class Scorer {
|
|||
newRecord = currentScore > maxScore;
|
||||
}
|
||||
|
||||
public int getCurrentScore() {
|
||||
return currentScore;
|
||||
}
|
||||
|
||||
public void saveScore() {
|
||||
if (newRecord) {
|
||||
prefs.putInteger("maxScore", currentScore);
|
||||
|
@ -84,7 +91,7 @@ public class Scorer {
|
|||
currentScoreLabel.setText(Integer.toString(MathUtils.round(shownScore)));
|
||||
}
|
||||
|
||||
batch.setColor(Color.WHITE);
|
||||
batch.setColor(Color.GOLD);
|
||||
batch.draw(cupTexture, cupArea.x, cupArea.y, cupArea.width, cupArea.height);
|
||||
currentScoreLabel.draw(batch, 1f);
|
||||
maxScoreLabel.draw(batch, 1f);
|
||||
|
|
|
@ -39,7 +39,7 @@ public class GameScreen implements Screen, InputProcessor {
|
|||
board = new Board(layout, 10);
|
||||
holder = new PieceHolder(layout, 3);
|
||||
|
||||
pauseMenu = new PauseMenuStage(game, scorer);
|
||||
pauseMenu = new PauseMenuStage(layout, game, scorer);
|
||||
}
|
||||
|
||||
private boolean isGameOver() {
|
||||
|
@ -115,7 +115,7 @@ public class GameScreen implements Screen, InputProcessor {
|
|||
@Override
|
||||
public boolean keyUp(int keycode) {
|
||||
if (keycode == Input.Keys.P) // Pause
|
||||
pauseMenu.show();
|
||||
pauseMenu.show(false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class GameScreen implements Screen, InputProcessor {
|
|||
|
||||
// After the piece was put, check if it's game over
|
||||
if (isGameOver()) {
|
||||
pauseMenu.show();
|
||||
pauseMenu.show(true);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -16,6 +16,8 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
|||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
|
||||
import io.github.lonamiwebs.klooni.Klooni;
|
||||
import io.github.lonamiwebs.klooni.actors.Band;
|
||||
import io.github.lonamiwebs.klooni.game.GameLayout;
|
||||
import io.github.lonamiwebs.klooni.game.Scorer;
|
||||
|
||||
public class PauseMenuStage extends Stage {
|
||||
|
@ -24,15 +26,21 @@ public class PauseMenuStage extends Stage {
|
|||
private boolean shown;
|
||||
private boolean hiding;
|
||||
|
||||
private Scorer scorer;
|
||||
private final Band band;
|
||||
private final Scorer scorer;
|
||||
|
||||
public PauseMenuStage(final Klooni game, final Scorer aScorer) {
|
||||
public PauseMenuStage(final GameLayout layout, final Klooni game, final Scorer aScorer) {
|
||||
scorer = aScorer;
|
||||
|
||||
Table table = new Table();
|
||||
table.setFillParent(true);
|
||||
addActor(table);
|
||||
|
||||
// Current and maximum score band.
|
||||
// Do not add it to the table not to over-complicate things.
|
||||
band = new Band(layout, scorer, Color.SKY);
|
||||
addActor(band);
|
||||
|
||||
// Home screen button
|
||||
ImageButton.ImageButtonStyle homeStyle = new ImageButton.ImageButtonStyle(
|
||||
game.skin.newDrawable("button_up", Color.FIREBRICK),
|
||||
|
@ -94,7 +102,7 @@ public class PauseMenuStage extends Stage {
|
|||
});
|
||||
}
|
||||
|
||||
void show() {
|
||||
void show(final boolean gameOver) {
|
||||
scorer.saveScore();
|
||||
|
||||
lastInputProcessor = Gdx.input.getInputProcessor();
|
||||
|
@ -102,6 +110,9 @@ public class PauseMenuStage extends Stage {
|
|||
shown = true;
|
||||
hiding = false;
|
||||
|
||||
if (gameOver)
|
||||
band.setGameOver();
|
||||
|
||||
addAction(Actions.moveTo(0, Gdx.graphics.getHeight()));
|
||||
addAction(Actions.moveTo(0, 0, 0.75f, Interpolation.swingOut));
|
||||
}
|
||||
|
@ -135,7 +146,6 @@ public class PauseMenuStage extends Stage {
|
|||
// Draw an overlay rectangle with not all the opacity
|
||||
if (shown) {
|
||||
ShapeRenderer shapeRenderer = new ShapeRenderer(20);
|
||||
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
|
||||
shapeRenderer.setColor(1f, 1f, 1f, 0.3f);
|
||||
|
|
Loading…
Reference in a new issue