Package menu

Source Code of menu.PauseMenu

package menu;

import java.awt.Font;

import com.threed.jpct.FrameBuffer;
import com.threed.jpct.World;

import font.GLFont;

public class PauseMenu implements IMenu{
  private MenuItem resumeGame;
  private MenuItem restartGame;
  private MenuItem goToMainMenu;
 
  private GLFont font;
 
  private int result;
 
  private MenuItem createMenuButton(String title, final int currentResult, int yPos, World world, FrameBuffer buffer){
    MenuItem menuItem = new MenuItem(world, buffer, font);
    menuItem.setPosition(80, yPos);
    menuItem.setText(title);
    menuItem.initialize();
   
    menuItem.addClickListener(new ClickEventHandler() {
     
      @Override
      public void onClick() {
        result = currentResult;
        //Logger.log("PAUSE RESULT: "+result);
      }
    })
    return menuItem;
  }
 
  @Override
  public void initialize(World world, FrameBuffer buffer){
    result = 0;
   
    //Logger.log("INIT PAUSE MENU");
    //create font
    font = new GLFont(new Font("Arial", Font.BOLD, 30));
   
    //init menu items
    resumeGame = createMenuButton("RESUME GAME", 1, 70, world, buffer);
    restartGame = createMenuButton("RESTART GAME", 2, 130, world, buffer);
    goToMainMenu = createMenuButton("BACK TO MAIN MANU", 3, 190, world, buffer);
  }
 
  @Override
  public void update(World world, FrameBuffer buffer){
    resumeGame.update();
    restartGame.update();
    goToMainMenu.update();
  }
 
  public void dispose(){
    resumeGame.dispose();
    restartGame.dispose();
    goToMainMenu.dispose();
  }
 
  public int getResult(){
    int r = result;
    result = 0;
    return r;
  }
}
TOP

Related Classes of menu.PauseMenu

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.