コード例 #1
0
        /**
         * Will initialize the various Menues and Buttons that are used by the game
         * This includes the Main Menue, Transition Menue, and Escape Menue
         */
        protected void initializeMenues()
        {
            //Main Menue
            mainMenue = new Menue();
            mainMenue.getBackGround().setCenter(BaseCode.worldWidth / 2, BaseCode.worldHeight / 2);
            mainMenue.getBackGround().setSize(BaseCode.worldWidth / 4f, BaseCode.worldHeight / 3f);
            mainMenue.getBackGround().rectangleVisible = false;
            mainMenue.setIdleImage(buttonUp);

            //Play Button
            LevelButton play = new LevelButton();

            play.setText("Play");
            play.getFont().targetFont             = defaultFont;
            play.getFont().textColor              = Color.Black;
            play.getBackGround().rectangleVisible = false;
            play.setLevel(this, currentLevel, LevelNumber);
            mainMenue.addButton(play);

            //Tidal
            MenueSystem.Panel tital = new MenueSystem.Panel();
            tital.getBackGround().setCenter(BaseCode.worldWidth / 2, BaseCode.worldHeight * 0.25f);
            tital.getBackGround().setSize(BaseCode.worldWidth / 2, BaseCode.worldHeight / 2);
            tital.setIdleImage(Logo);
            tital.getBackGround().rectangleVisible = false;
            mainMenue.addPanel(tital);

            //choseLevel
            MenueSystem.Button choseLevel = new MenueSystem.Button();
            choseLevel.getBackGround().rectangleVisible = false;
            choseLevel.setText("Choose Level");
            choseLevel.getFont().targetFont = defaultFont;
            choseLevel.getFont().textColor  = Color.Black;
            choseLevel.selectable = true;
            choseLevel.setIdleImage(buttonUp);
            choseLevel.setButtonDownImage(buttonDown);
            choseLevel.setMouseOverIdleImage(buttonMouseOver);
            choseLevel.setMouseOverSelectImage(buttonMouseOver);
            choseLevel.setSelectImage(buttonUp);
            choseLevel.getBackGround().rectangleVisible = false;
            mainMenue.addButton(choseLevel);

            //LevelMenue
            MenueSystem.Menue LevelMenue = new MenueSystem.Menue();
            LevelMenue = new Menue();
            LevelMenue.getBackGround().rectangleVisible = false;
            LevelMenue.getBackGround().setCenter(BaseCode.worldWidth * 0.75f, BaseCode.worldHeight / 2);
            LevelMenue.getBackGround().setSize(BaseCode.worldWidth / 4, BaseCode.worldHeight * 0.8f);
            LevelMenue.setIdleImage(buttonUp);
            choseLevel.addPanel(LevelMenue);
            //Adding Levels
            if (tempList != null)
            {
                while (tempList.Count > 0)
                {
                    LevelButton newLevel          = new LevelButton();
                    newLevel.getFont().targetFont = defaultFont;
                    newLevel.setText(tempNameList.Dequeue());
                    newLevel.getBackGround().rectangleVisible = false;
                    newLevel.getFont().textColor = Color.Black;
                    newLevel.setLevel(this, tempList.Dequeue());
                    newLevel.winMessage  = tempWinList.Dequeue();
                    newLevel.loseMessage = tempLoseList.Dequeue();
                    LevelMenue.addButton(newLevel);
                }
                LevelMenue.setButtonSizesPositions(true);
                tempList     = null;
                tempNameList = null;
                tempWinList  = null;
                tempLoseList = null;
            }
            mainMenue.setButtonSizesPositions(true);
            mainMenue.setState(MenueSystem.Panel.PanelState.IDLE, true);
            BaseCode.activeDrawSet.addToDrawSet(mainMenue);
            mainMenue.setPriority(9);

            //Transition Menu
            transitionMenue = new Menue();
            transitionMenue.getBackGround().setCenter(BaseCode.worldWidth / 2, BaseCode.worldHeight / 2);
            transitionMenue.getBackGround().setSize(BaseCode.worldWidth / 4, BaseCode.worldHeight / 4);
            transitionMenue.getBackGround().rectangleVisible = false;
            transitionMenue.setIdleImage(buttonUp);
            //replay Level
            LevelButton replay = new LevelButton();

            replay.setText("Replay Level");
            replay.getFont().targetFont             = defaultFont;
            replay.getFont().textColor              = Color.Black;
            replay.getBackGround().rectangleVisible = false;
            transitionMenue.addButton(replay);
            //Next Level
            LevelButton next = new LevelButton();

            next.getFont().targetFont = defaultFont;
            next.setText("Next Level");
            next.getFont().textColor = Color.Black;
            next.getBackGround().rectangleVisible = false;
            transitionMenue.addButton(next);

            MenueSystem.Label WinLose = new MenueSystem.Label();
            WinLose.getFont().textPosition.X = BaseCode.worldWidth * 0.4f;
            WinLose.getFont().textPosition.Y = BaseCode.worldHeight * 0.3f;
            WinLose.getFont().targetFont = defaultFont;
            WinLose.setText("");
            WinLose.getFont().textColor = Color.Black;
            WinLose.getBackGround().rectangleVisible = false;
            transitionMenue.addPanel(WinLose);

            transitionMenue.setButtonSizesPositions(true);
            transitionMenue.setState(MenueSystem.Panel.PanelState.IDLE, true);

            transitionMenue.addToDrawSet(BaseCode.activeDrawSet);
            transitionMenue.setPriority(9);

            //Escape Menu
            escapeMenue = new MenueSystem.Menue();
            escapeMenue.getBackGround().setCenter(BaseCode.worldWidth / 2, BaseCode.worldHeight / 2);
            escapeMenue.getBackGround().setSize(BaseCode.worldWidth / 4, BaseCode.worldHeight / 4);
            escapeMenue.getBackGround().rectangleVisible = false;
            escapeMenue.setIdleImage(buttonUp);
            //Resume Game
            ChangeGameStateButton resume = new ChangeGameStateButton();

            resume.getFont().targetFont = defaultFont;
            resume.setText("Resume Game");
            resume.getFont().textColor = Color.Black;
            resume.setTargetState(this, updateState.INGAME);
            resume.getBackGround().rectangleVisible = false;
            escapeMenue.addButton(resume);
            //To Main Menue
            ChangeGameStateButton toMain = new ChangeGameStateButton();

            toMain.getFont().targetFont = defaultFont;
            toMain.setText("Main Menu");
            toMain.getFont().textColor = Color.Black;
            toMain.setTargetState(this, updateState.MAINMENUE);
            toMain.getBackGround().rectangleVisible = false;
            escapeMenue.addButton(toMain);

            escapeMenue.setButtonSizesPositions(true);
            escapeMenue.setState(MenueSystem.Panel.PanelState.IDLE, true);
            escapeMenue.addToDrawSet(BaseCode.activeDrawSet);
            escapeMenue.setPriority(9);
        }