Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


How do I stop my game from skipping screens?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Slateboard   Members   -  Reputation: 204

Like
0Likes
Like

Posted 25 April 2012 - 06:53 PM

I used the code from this - http://www.xnadevelo...eofthings.shtml (The second method using enumerations)

I modified it to add a 3rd screen for gameplay and it functioned like the previous screen. The issue is that since the Controller Detect Screen and Title Screen both use the A button to advance. Because of this, it advances through both at the same time, going straight to the gameplay screen. I changed the code (as seen below) so that the Title Screen uses a different button. However, I want to have it so it uses the same button, but not advance at the same time.

Hopefully I explained it correctly.

private void UpdateControllerDetectScreen()
		{

			//Poll all the gamepads (and the keyboard) to check to see

			//which controller will be the player one controller

			for (int aPlayer = 0; aPlayer < 4; aPlayer++)
			{

				if (GamePad.GetState((PlayerIndex)aPlayer).Buttons.A == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.A) == true)
				{

					mPlayerOne = (PlayerIndex)aPlayer;

					mCurrentScreen = ScreenState.Title;

					return;

				}

			}

		}

		private void UpdateTitleScreen()
		{

			//Move back to the Controller detect screen if the player moves

			//back (using B) from the Title screen (this is typical game behavior

			//and is used to switch to a new player one controller)

			if (GamePad.GetState(mPlayerOne).Buttons.B == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.B) == true)
			{

				mCurrentScreen = ScreenState.ControllerDetect;

				return;

			}

			if (GamePad.GetState((PlayerIndex)mPlayerOne).Buttons.A == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.C) == true)
			{



				mCurrentScreen = ScreenState.GamePlay;

				return;

			}

		}

		private void UpdateGamePlayScreen()
		{

			//Move back to the Controller detect screen if the player moves

			//back (using B) from the Title screen (this is typical game behavior

			//and is used to switch to a new player one controller)

			if (GamePad.GetState(mPlayerOne).Buttons.B == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.B) == true)
			{

				mCurrentScreen = ScreenState.Title;

				return;

			}

	



		}


Sponsor:

#2 TheTroll   Members   -  Reputation: 882

Like
1Likes
Like

Posted 25 April 2012 - 06:58 PM

Just add a bool flag for which screen you are on.

Then add
if(OnTitleScreen == true)
{
   // do title stuff
}
else
{
    //do other screen.
}


#3 Slateboard   Members   -  Reputation: 204

Like
0Likes
Like

Posted 26 April 2012 - 06:25 AM

That's been fixed.

Thanks.

#4 way2lazy2care   Members   -  Reputation: 782

Like
0Likes
Like

Posted 26 April 2012 - 07:19 AM

There's a pretty good sample up on the XNA creators club site for screen switching that supports pause menus etc. May be worth looking into.

#5 Slateboard   Members   -  Reputation: 204

Like
0Likes
Like

Posted 26 April 2012 - 09:24 AM

I've seen their Game State Management example, but it looked complicated with little to no information in regards to how things work.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS