Android Open Source - Terry-Coin Game State Manager






From Project

Back to project page Terry-Coin.

License

The source code is released under:

Apache License

If you think the Android project Terry-Coin listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.tcg.terry.managers;
//w  w  w.j ava  2  s .c  o  m
import com.tcg.terry.gamestates.*;


public class GameStateManager {
  
  private GameState gameState;
  
  public final int SPLASH = 0;
  public final int MENU = 1;
  public final int PLAY = 2;
  public final int GAMEOVER = 3;
  public final int CONTROLS = 4;
  
  public GameStateManager() {
    setState(SPLASH);
  }
  
  public void update(float dt) {
    gameState.update(dt);
  }
  
  public void draw() {
    gameState.draw();
  }
  
  public void setState(int state) {
    if(gameState != null) gameState.dispose();
    if(state == SPLASH) {
      gameState = new SplashState(this);
    }
    if(state == MENU) {
      gameState = new MenuState(this);
    }
    if(state == PLAY) {
      gameState = new PlayState(this);
    }
    if(state == CONTROLS) {
      gameState = new ControlsState(this);
    }
  }
  
  public void GameOver(long c) {
    gameState = new GameOverState(this, c);
  }

}




Java Source Code List

com.tcg.terry.MainActivity.java
com.tcg.terry.Main.java
com.tcg.terry.entities.Button.java
com.tcg.terry.entities.Cloud.java
com.tcg.terry.entities.Coin.java
com.tcg.terry.entities.Cursor.java
com.tcg.terry.entities.Flower.java
com.tcg.terry.entities.Ground.java
com.tcg.terry.entities.JumpButton.java
com.tcg.terry.entities.MenuButton.java
com.tcg.terry.entities.Player.java
com.tcg.terry.entities.SprintButton.java
com.tcg.terry.gamestates.ControlsState.java
com.tcg.terry.gamestates.GameOverState.java
com.tcg.terry.gamestates.GameState.java
com.tcg.terry.gamestates.MenuState.java
com.tcg.terry.gamestates.PlayState.java
com.tcg.terry.gamestates.SplashState.java
com.tcg.terry.main.Game.java
com.tcg.terry.managers.Content.java
com.tcg.terry.managers.GameStateManager.java
com.tcg.terry.managers.Timer.java