當前位置: 首頁>>代碼示例>>C#>>正文


C# GameState.Initialize方法代碼示例

本文整理匯總了C#中GameState.Initialize方法的典型用法代碼示例。如果您正苦於以下問題:C# GameState.Initialize方法的具體用法?C# GameState.Initialize怎麽用?C# GameState.Initialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GameState的用法示例。


在下文中一共展示了GameState.Initialize方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SwitchState

 public static void SwitchState(GameState newstate)
 {
     if (CurrentState != null) {
         CurrentState.Uninitialize();
     }
     newstate.Initialize();
     CurrentState = newstate;
 }
開發者ID:CloneDeath,項目名稱:PokemonSmash,代碼行數:8,代碼來源:Program.cs

示例2: HandleGameState

 /// <summary>
 /// should be called when curr != prev
 /// </summary>
 void HandleGameState()
 {
     switch (curr)
     {
         case EGameState.None:
             win.Close();
             break;
         case EGameState.TitleScreen:
             state = new TitleScreen();
             state.LoadContent();
             state.Initialize();
             break;
         default:
             break;
     }
 }
開發者ID:endert,項目名稱:Intro2D,代碼行數:19,代碼來源:Game.cs

示例3: Initialize

 public void Initialize(GameState initialState, SpriteBatch spriteBatch)
 {
     this.spriteBatch = spriteBatch;
     _currentState = initialState;
     _currentState.Initialize(spriteBatch);
 }
開發者ID:PedroKinetica,項目名稱:veggie-zombies,代碼行數:6,代碼來源:GameStateManager.cs

示例4: LoadContent

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Should probably be in Initialize, but screen size is updated after Initialize causing weird collision issues
            Vector2 screenSize = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.Right, GraphicsDevice.Viewport.TitleSafeArea.Bottom);
            game = new StateGame(screenSize);
            levelMenu = new StateLevelSelect(screenSize, "Map Select", new string[] { "Start", "Start", "Quit" }, game);
            creditsMenu = new StateCredits(screenSize, "Credits", new string[] { "Menu" });
            charMenu = new StateCharacterSelect(screenSize, "Character Select", levelMenu, game);
            //mainMenu = new StateSimpleMenu(screenSize, "Blink", new string[] { "Start", "Credits", "Quit" }, new GameState[] { charMenu, creditsMenu, new StateQuit() });
            mainMenu = new StateMainMenu(screenSize, new GameState[] { charMenu, creditsMenu, new StateQuit() });
            winScreen = new StateWin(screenSize);
            ((StateGame)game).levelSelect = levelMenu;
            ((StateGame)game).Win = winScreen;
            ((StateCredits)creditsMenu).getMenu(mainMenu);
            ((StateLevelSelect)levelMenu).prevState = charMenu;
            ((StateWin)winScreen).levelSelect = levelMenu;
            currState = mainMenu;
            currState.Initialize();
            currState.LoadContent(Content);
            AudioManager.LoadContent(Content);
        }
開發者ID:dah6ce,項目名稱:Blink,代碼行數:28,代碼來源:Game1.cs

示例5: Update

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape) || !running)
                Exit();

            currState.Update(gameTime);
            AudioManager.Update(gameTime);

            // Handle GameState transitions
            GameState newState = currState.GetTransition();
            if (newState != null)
            {
                //Set map
                if(newState == game)
                    ((StateGame)game).setMaps(((StateLevelSelect)levelMenu).getSelectedMap());
                if (newState == winScreen)
                {
                    ((StateWin)winScreen).setMap(((StateLevelSelect)levelMenu).getSelectedMap().getName()+"/victory");
                    ((StateWin)winScreen).setPlayers(((StateGame)game).players);
                }

                //State unload/load
                currState.UnloadContent();
                currState = newState;
                currState.Initialize();
                currState.LoadContent(Content);

            }

            base.Update(gameTime);
        }
開發者ID:dah6ce,項目名稱:Blink,代碼行數:36,代碼來源:Game1.cs


注:本文中的GameState.Initialize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。