"Press" Enter "to start the game" XNA INTRO SCREEN

I created a screen saver that says "Press Enter to start the game," (and exit) to exit the game, this is not a problem, but to make the game start a little more complicated. Any tips?

+3
source share
3 answers

The easiest way to do this is to set up a state machine. It would look very simple.

enum GameState 
{
TitleScreen = 0,
GameStarted
GameEnded
}

Something then in Game1.cs or wherever you process this button, you can put the variable in your class to save the current state of the game you are in.

GameState currentGameState = GameState.TitleScreen;

, , ,

void Draw(GameTime time)
{
   if(currentGameState == GameStarted)
   {
       //Then handle the game drawing code here

   }
}

+2

, , ( )

, IContext. void Draw() void Update().

IContext, Context. context.update() context.draw() gameloop.

IContext. , .

, "" , Enter, this.game.context = new level01();

, .

+1

Since ninename says that the state machine is the way here. However, I would say that you look at this sample - http://create.msdn.com/en-US/education/catalog/sample/game_state_management - provided by Microsoft, and not your own. It is very easy to implement and modify a whist covering prety with a lot of everything you could do, including input processing.

+1
source

Source: https://habr.com/ru/post/1769963/


All Articles