Пример #1
0
  /**
   * Draws the menu to the screen.
   *
   * @param gameState the current state of the application
   * @param spriteBatch graphics context to draw to
   */
  public void draw(GameScreen.GameState gameState, SpriteBatch spriteBatch) {
    for (ButtonBall option : mMenuOptionBalls) option.draw(spriteBatch, mTextureManager);

    FontManager.getDefaultFont()
        .draw(
            spriteBatch,
            "Tap to begin",
            GameScreen.getScreenWidth() / 2,
            GameScreen.getScreenHeight() / 2);
  }
Пример #2
0
  /**
   * Sets up a new main menu.
   *
   * @param callback instance of callback interface
   * @param textureManager to get textures to draw
   */
  public MenuManager(MenuCallback callback, TextureManager textureManager) {
    mCallback = callback;
    mTextureManager = textureManager;

    BasicBall.initialize(GameScreen.getScreenWidth(), GameScreen.getScreenHeight());
    mMenuOptionBalls = new ButtonBall[MenuBallOption.getSize()];
    mMenuOptionBalls[MenuBallOption.MusicOn.ordinal()] =
        new ButtonBall(
            MenuBallOption.MusicOn,
            TextureManager.GameColor.Green,
            textureManager.getMenuButtonIconTexture(MenuBallOption.MusicOn),
            GameScreen.getScreenWidth() / 2 - BasicBall.getDefaultBallRadius() * 2,
            GameScreen.getScreenHeight() / 2);
    mMenuOptionBalls[MenuBallOption.MusicOff.ordinal()] =
        new ButtonBall(
            MenuBallOption.MusicOff,
            TextureManager.GameColor.Red,
            textureManager.getMenuButtonIconTexture(MenuBallOption.MusicOff),
            GameScreen.getScreenWidth() / 2 - BasicBall.getDefaultBallRadius() * 2,
            GameScreen.getScreenHeight() / 2);
    mMenuOptionBalls[MenuBallOption.SoundEffectsOn.ordinal()] =
        new ButtonBall(
            MenuBallOption.SoundEffectsOn,
            TextureManager.GameColor.Green,
            textureManager.getMenuButtonIconTexture(MenuBallOption.SoundEffectsOn),
            GameScreen.getScreenWidth() / 2 + BasicBall.getDefaultBallRadius() * 2,
            GameScreen.getScreenHeight() / 2);
    mMenuOptionBalls[MenuBallOption.SoundEffectsOff.ordinal()] =
        new ButtonBall(
            MenuBallOption.SoundEffectsOff,
            TextureManager.GameColor.Red,
            textureManager.getMenuButtonIconTexture(MenuBallOption.SoundEffectsOff),
            GameScreen.getScreenWidth() / 2 + BasicBall.getDefaultBallRadius() * 2,
            GameScreen.getScreenHeight() / 2);
    for (ButtonBall ball : mMenuOptionBalls)
      ball.setScalingCompleteListener(mMenuOptionBallsListener);
  }