Android Open Source - X3n0break Menu Screen






From Project

Back to project page X3n0break.

License

The source code is released under:

GNU General Public License

If you think the Android project X3n0break 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 org.x3n0m0rph59.breakout;
//  w  ww . j av a2 s .c  o  m
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.StretchViewport;

public class MenuScreen implements Screen {

  private final OrthographicCamera camera;
  private final StretchViewport viewport;

  BitmapFont font;
  BitmapFont smallFont;

  public MenuScreen() {
    camera = new OrthographicCamera();
    camera.setToOrtho(true, Config.WORLD_WIDTH, Config.WORLD_HEIGHT);
    camera.update();

    viewport = new StretchViewport(Config.WORLD_WIDTH, Config.WORLD_HEIGHT,
        camera);
    viewport.apply(true);

    font = FontLoader.getInstance().getFont("font", Config.TOAST_FONT_SIZE);
    smallFont = FontLoader.getInstance().getFont("small_font",
        Config.TOAST_FONT_SIZE);
  }

  @Override
  public void show() {
    final MenuInputProcessor inputProcessor = new MenuInputProcessor();
    Gdx.input.setInputProcessor(inputProcessor);

    font = FontLoader.getInstance().getFont("font", Config.TOAST_FONT_SIZE);
    smallFont = FontLoader.getInstance().getFont("small_font",
        Config.TOAST_FONT_SIZE);
    
    if (!SoundLayer.isMusicPlaying())
      SoundLayer.playMusic(Musics.BACKGROUND);    
  }

  @Override
  public void render(float delta) {
    final SpriteBatch batch = App.getSpriteBatch();

    batch.setProjectionMatrix(camera.combined);

    font.draw(batch, "Main Menu", 50, 50);
    
    font.draw(batch, "NEW GAME", 150, 250);
    
    if (Config.getInstance().isGameResumeable() && 
      Config.getInstance().getGameStateBeforeQuit() != GameScreen.State.GAME_OVER && 
      Config.getInstance().getGameStateBeforeQuit() != GameScreen.State.LEVEL_SET_COMPLETED &&
      (Config.getInstance().getGameStateBeforeQuit() != GameScreen.State.NEW_STAGE && GameState.getLevel() == 0))
      font.draw(batch, "RESUME GAME", 1300, 250);
      
    font.draw(batch, "SETTINGS", 150, 550);
    font.draw(batch, "HIGHSCORES", 150, 750);
    
    font.draw(batch, "HELP", 1300, 550);
    font.draw(batch, "EXIT", 1300, 750);

    smallFont.draw(batch, Config.APP_NAME + " " + Config.APP_VERSION, 1700, 1000);
  }

  @Override
  public void resize(int width, int height) {
    viewport.update(width, height, true);
  }

  @Override
  public void pause() {
    // TODO Auto-generated method stub

  }

  @Override
  public void resume() {
    // TODO Auto-generated method stub

  }

  @Override
  public void hide() {
    // TODO Auto-generated method stub

  }

  @Override
  public void dispose() {
     font.dispose();
     smallFont.dispose();
  }

  public Camera getCamera() {
    return camera;
  }
}




Java Source Code List

org.x3n0m0rph59.breakout.App.java
org.x3n0m0rph59.breakout.BackgroundFactory.java
org.x3n0m0rph59.breakout.Background.java
org.x3n0m0rph59.breakout.Ball.java
org.x3n0m0rph59.breakout.BottomWall.java
org.x3n0m0rph59.breakout.Brick.java
org.x3n0m0rph59.breakout.Config.java
org.x3n0m0rph59.breakout.Destroyable.java
org.x3n0m0rph59.breakout.EffectManager.java
org.x3n0m0rph59.breakout.Effect.java
org.x3n0m0rph59.breakout.FontLoader.java
org.x3n0m0rph59.breakout.FontTuple.java
org.x3n0m0rph59.breakout.ForceFeedback.java
org.x3n0m0rph59.breakout.GameInputProcessor.java
org.x3n0m0rph59.breakout.GameObject.java
org.x3n0m0rph59.breakout.GameScreen.java
org.x3n0m0rph59.breakout.GameState.java
org.x3n0m0rph59.breakout.GrapplingHookSegment.java
org.x3n0m0rph59.breakout.GrapplingHook.java
org.x3n0m0rph59.breakout.HelpInputProcessor.java
org.x3n0m0rph59.breakout.HelpScreen.java
org.x3n0m0rph59.breakout.HighScoreManager.java
org.x3n0m0rph59.breakout.HighScoreScreen.java
org.x3n0m0rph59.breakout.HighScore.java
org.x3n0m0rph59.breakout.HighscoreInputProcessor.java
org.x3n0m0rph59.breakout.IOSLauncher.java
org.x3n0m0rph59.breakout.LevelLoader.java
org.x3n0m0rph59.breakout.LevelSetSelectorInputProcessor.java
org.x3n0m0rph59.breakout.LevelSetSelectorScreen.java
org.x3n0m0rph59.breakout.Logger.java
org.x3n0m0rph59.breakout.MenuInputProcessor.java
org.x3n0m0rph59.breakout.MenuScreen.java
org.x3n0m0rph59.breakout.MusicLoader.java
org.x3n0m0rph59.breakout.MusicStream.java
org.x3n0m0rph59.breakout.ObjectPool.java
org.x3n0m0rph59.breakout.Paddle.java
org.x3n0m0rph59.breakout.ParticleSystem.java
org.x3n0m0rph59.breakout.Particle.java
org.x3n0m0rph59.breakout.Point.java
org.x3n0m0rph59.breakout.Poolable.java
org.x3n0m0rph59.breakout.Powerup.java
org.x3n0m0rph59.breakout.Projectile.java
org.x3n0m0rph59.breakout.Renderable.java
org.x3n0m0rph59.breakout.ResourceMapperDecisionCache.java
org.x3n0m0rph59.breakout.ResourceMapper.java
org.x3n0m0rph59.breakout.ScoreBoard.java
org.x3n0m0rph59.breakout.ScreenManager.java
org.x3n0m0rph59.breakout.ScreenType.java
org.x3n0m0rph59.breakout.SettingsInputProcessor.java
org.x3n0m0rph59.breakout.SettingsScreen.java
org.x3n0m0rph59.breakout.SoundLayer.java
org.x3n0m0rph59.breakout.SoundLoader.java
org.x3n0m0rph59.breakout.SoundSprite.java
org.x3n0m0rph59.breakout.SpaceBomb.java
org.x3n0m0rph59.breakout.SpriteLoader.java
org.x3n0m0rph59.breakout.SpriteObject.java
org.x3n0m0rph59.breakout.SpriteTuple.java
org.x3n0m0rph59.breakout.Star.java
org.x3n0m0rph59.breakout.Stepable.java
org.x3n0m0rph59.breakout.TextAnimationManager.java
org.x3n0m0rph59.breakout.TextAnimation.java
org.x3n0m0rph59.breakout.Util.java
org.x3n0m0rph59.breakout.Vector.java
org.x3n0m0rph59.breakout.android.AndroidLauncher.java
org.x3n0m0rph59.breakout.client.HtmlLauncher.java
org.x3n0m0rph59.breakout.desktop.DesktopLauncher.java