本文整理汇总了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;
}
示例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;
}
}
示例3: Initialize
public void Initialize(GameState initialState, SpriteBatch spriteBatch)
{
this.spriteBatch = spriteBatch;
_currentState = initialState;
_currentState.Initialize(spriteBatch);
}
示例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);
}
示例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);
}