本文整理汇总了C#中GameState.LoadContent方法的典型用法代码示例。如果您正苦于以下问题:C# GameState.LoadContent方法的具体用法?C# GameState.LoadContent怎么用?C# GameState.LoadContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameState
的用法示例。
在下文中一共展示了GameState.LoadContent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeState
private void ChangeState()
{
if (_currentState != null)
_currentState.UnloadContent();
_currentState = _nextGameState;
_currentState.LoadContent();
_currentState.Init();
}
示例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: 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);
}
示例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: add
private void add(GameState gameState)
{
if (!GameStates.Contains(gameState))
{
gameState.LoadContent();
GameStates.Add(gameState);
}
}