コード例 #1
0
 private void StartState()
 {
     switch (_state)
     {
         case "MainMenu":
             _menu = new MainMenu(this);
             AddChild(_menu);
             break;
         case "Level1":
             _level = new Level.Level("tiger 4.tmx", this);
             AddChild(_level);
             break;
         case "Level2":
             _level = new Level.Level("rocket.tmx", this);
             AddChild(_level);
             break;
         case "Credits":
             _credits = new Credits(this);
             AddChild(_credits);
             break;
         case "Exit":
             Environment.Exit(0);
             break;
         default:
             throw new Exception("You tried to load a non-existant state");
     }
 }
コード例 #2
0
        private void StopState()
        {
            switch (_state)
            {
                case "MainMenu":
                    _menu.StopMusic();
                    _menu.Destroy();
                    _menu = null;
                    break;
                case "Level1":
                    _level.Destroy();
                    _level = null;
                    break;
                case "Level2":
                    _level.Destroy();
                    _level = null;
                    break;
                case "Credits":
                    _credits.Destroy();
                    _credits = null;
                    break;

            }
        }