当前位置: 首页>>代码示例>>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;未经允许,请勿转载。