Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9009977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:20:22+00:00 2026-06-16T02:20:22+00:00

I get these three error messages in the switch block of Game1 class but

  • 0

I get these three error messages in the switch block of Game1 class but I don’t know how to fix them. What is wrong?
The name ‘IntroState’ does not exist in the current context
The name ‘MenuState’ does not exist in the current context
The name ‘MaingameState’ does not exist in the current context

In addition, I get this error message in the Intro class:
The name ‘IntroState’ does not exist in the current context

public class Game1 : Microsoft.Xna.Framework.Game
{
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;
    IState currentState;

    public enum GameStates
    {
        IntroState = 0,
        MenuState = 1,
        MaingameState = 2,
    }


    public void ChangeGameState(GameStates newState)
    {
        switch (newState)
        {
            case IntroState:
                currentState = new Intro(this);
                break;
            case MenuState:
                currentState = new Menu(this);
                break;
            case MaingameState:
                currentState = new Maingame(this);
                break;
        }
        currentState.Load(Content);
    }


    public GameStates CurrentState
    {
        get { return currentGameState; }
        set { currentGameState = value; }
    }

    private GameStates currentGameState = GameStates.IntroState;


    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
    }

    protected override void Initialize()
    {
        currentState = new Intro(this);
        base.Initialize();
    }

    protected override void LoadContent()
    {       
        spriteBatch = new SpriteBatch(GraphicsDevice);
        currentState.Load(Content);
    }

    protected override void Update(GameTime gameTime)
    {
        currentState.Update(gameTime);     
        KeyboardState kbState = Keyboard.GetState();
        base.Update(gameTime);
    }

    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);
        spriteBatch.Begin();
        currentState.Render(spriteBatch);
        spriteBatch.End();

        base.Draw(gameTime);
    }
}

public interface IState
    {
        void Load(ContentManager content);
        void Update(GameTime gametime);
        void Render(SpriteBatch batch);
    }


public class Intro : IState
{
    Texture2D Introscreen;
    private Game1 game1;       

    public Intro(Game1 game)
    {
        game1 = game;
    }

    public void Load(ContentManager content)
    {
       Introscreen = content.Load<Texture2D>("intro");
    }

    public void Update(GameTime gametime)
    {
        KeyboardState kbState = Keyboard.GetState();
        if (kbState.IsKeyDown(Keys.Space))
          game1.ChangeGameState(IntroState);
    }

    public void Render(SpriteBatch batch)
    {
        batch.Draw(Introscreen, new Rectangle(0, 0, 1280, 720), Color.White);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:20:23+00:00Added an answer on June 16, 2026 at 2:20 am

    An enum value can only be used when prefixed with the type-name:

      //case IntroState:
        case GameStates.IntroState:
    

    you can never use IntroState on its own.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

and get meaningful results. Currently I am running these three queries: SELECT t.type,t.id,s.title FROM
I am using SQLite. When I execute a query, I get error messages such
I get an exception with the message: There is an error in XML document.
When we try to create a view within a funcion we get ERROR: there
When debugging in Visual Studio 2008 I get the error There is no source
while executing the following query, i get an error that there's an error in
What's the maximum length of an HTTP GET request? Is there a response error
I get the following error when trying to run my application. There are no
I get the error: Msg 2714, Level 16, State 1, Line 16 There is
I get this error all the time. And as I can see, there are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.