Skip to content
Snippets Groups Projects
Commit 0bde3edf authored by Haakon Gunleiksrud's avatar Haakon Gunleiksrud
Browse files

Merge branch '62-scorestate' into 'dev'

Resolve "ScoreState"

Closes #62

See merge request !59
parents 0a792a7a 9948812c
No related branches found
No related tags found
1 merge request!59Resolve "ScoreState"
frontend/android/assets/bg_score.jpg

20 KiB

...@@ -47,8 +47,6 @@ public class BubbleWrapState extends PlayStateTemplate { ...@@ -47,8 +47,6 @@ public class BubbleWrapState extends PlayStateTemplate {
// Creates the bubbles, the table to put them in and adds them to the stage as Actors // Creates the bubbles, the table to put them in and adds them to the stage as Actors
createBubbles(); createBubbles();
createBubbleWrapLayout(); createBubbleWrapLayout();
Gdx.input.setInputProcessor(stage);
} }
@Override @Override
...@@ -73,6 +71,7 @@ public class BubbleWrapState extends PlayStateTemplate { ...@@ -73,6 +71,7 @@ public class BubbleWrapState extends PlayStateTemplate {
@Override @Override
public void update(float dt) { public void update(float dt) {
Gdx.input.setInputProcessor(stage);
this.handleInput(); this.handleInput();
this.currentTime += dt; this.currentTime += dt;
......
...@@ -181,6 +181,7 @@ public class CreateJoinTournamentState extends State { ...@@ -181,6 +181,7 @@ public class CreateJoinTournamentState extends State {
@Override @Override
public void update(float dt) { public void update(float dt) {
Gdx.input.setInputProcessor(stage);
stage.act(dt); stage.act(dt);
} }
......
package com.gameware.game.states; package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label;
...@@ -103,7 +104,10 @@ public class MenuState extends State{ ...@@ -103,7 +104,10 @@ public class MenuState extends State{
protected void handleInput() { } protected void handleInput() { }
@Override @Override
public void update(float dt) { stage.act(dt); } public void update(float dt) {
Gdx.input.setInputProcessor(stage);
stage.act(dt);
}
@Override @Override
public void render(SpriteBatch sb) { stage.draw(); } public void render(SpriteBatch sb) { stage.draw(); }
......
...@@ -43,9 +43,11 @@ public abstract class PlayStateTemplate extends State { ...@@ -43,9 +43,11 @@ public abstract class PlayStateTemplate extends State {
} }
GameWare.getInstance().updateGameMap(id, new ColorRushState(gsm)); GameWare.getInstance().updateGameMap(id, new ColorRushState(gsm));
if(round == null) { if(round == null) {
gsm.set(new SinglePlayerSelectGameState(gsm)); gsm.set(new ScoreState(gsm, this.score, new SinglePlayerSelectGameState(gsm)));
} else{ } else{
gsm.set(new ViewTournamentState(gsm, tournament, nextRound)); //TODO: nextRound blir null :/
// gsm.set(new ScoreState(gsm, this.score, new ViewTournamentState(gsm, tournament, nextRound)));
gsm.set(new ScoreState(gsm, this.score, new CreateJoinTournamentState(gsm)));
} }
} }
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.gameware.game.models.Round;
import com.gameware.game.models.Tournament;
public class ScoreState extends State {
private int score;
private State nextState;
private float currentTime = 0f;
private Table table;
private Label titleLabel = new Label("Your score:", skin, "big");
private Label continueLabel = new Label("Touch to continue", skin);
public ScoreState(GameStateManager gsm, int score, State nextState){
super(gsm);
this.score = score;
this.nextState = nextState;
makeStage();
}
private void makeStage(){
table = new Table();
table.setFillParent(true);
table.setBackground(backgroundScore);
titleLabel.setFontScale(titleFontBigScale);
table.add(titleLabel).spaceBottom(spacingOnBottom);
table.row();
Label scoreLabel = new Label(score+"", skin, "big");
scoreLabel.setFontScale(titleFontBigScale);
table.add(scoreLabel).spaceBottom(spacingOnBottomInputFIeld);
table.row();
table.add(continueLabel);
stage.addActor(table);
}
private void handleTouch(){
gsm.set(nextState);
}
@Override
protected void handleInput() {
if (Gdx.input.justTouched()) {
handleTouch();
}
}
@Override
public void update(float dt) {
this.currentTime += dt;
if(currentTime>2f){
this.handleInput();
}
stage.act(dt);
}
@Override
public void render(SpriteBatch sb) {
stage.draw();
}
@Override
public void dispose() {
stage.dispose();
}
@Override
public void reset() {
}
@Override
public Object report() {
return null;
}
}
package com.gameware.game.states; package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label;
...@@ -56,6 +57,7 @@ public class SinglePlayerSelectGameState extends State { ...@@ -56,6 +57,7 @@ public class SinglePlayerSelectGameState extends State {
@Override @Override
public void update(float dt) { public void update(float dt) {
Gdx.input.setInputProcessor(stage);
stage.act(); stage.act();
} }
......
...@@ -26,6 +26,7 @@ public abstract class State { ...@@ -26,6 +26,7 @@ public abstract class State {
protected static final int buttonHeight = Gdx.graphics.getHeight()/12; protected static final int buttonHeight = Gdx.graphics.getHeight()/12;
protected TextureRegionDrawable background = new TextureRegionDrawable(new TextureRegion(new Texture("bg1.jpg"))); protected TextureRegionDrawable background = new TextureRegionDrawable(new TextureRegion(new Texture("bg1.jpg")));
protected TextureRegionDrawable backgroundLighter = new TextureRegionDrawable(new TextureRegion(new Texture("bg1_lighter.jpg"))); protected TextureRegionDrawable backgroundLighter = new TextureRegionDrawable(new TextureRegion(new Texture("bg1_lighter.jpg")));
protected TextureRegionDrawable backgroundScore = new TextureRegionDrawable(new TextureRegion(new Texture("bg_score.jpg")));
protected State(GameStateManager gsm){ protected State(GameStateManager gsm){
this.gsm = gsm; this.gsm = gsm;
......
package com.gameware.game.states; package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label;
...@@ -118,6 +119,7 @@ public class ViewTournamentState extends State { ...@@ -118,6 +119,7 @@ public class ViewTournamentState extends State {
@Override @Override
public void update(float dt) { public void update(float dt) {
Gdx.input.setInputProcessor(stage);
stage.act(dt); stage.act(dt);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment