开发者

C# XNA - 'Game' is a 'namespace' but is used like a 'type'

开发者 https://www.devze.com 2023-01-22 05:39 出处:网络
I don\'t understand how to fix this problem, what am I suppose to change \'Game\' too? namespace Game {

I don't understand how to fix this problem, what am I suppose to change 'Game' too?

 namespace Game {

    public class Help : Microsoft.Xna.Framework.GameCo开发者_Go百科mponent
    {
        public Help(Game game): base(game)
        {
           // TODO: Construct any child components here
        }

        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }

        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

            base.Update(gameTime);
        }
    } 
 }


Rename your namespace 'Game' to something like MikesGame:

 namespace MikesGame {

    public class Help : Microsoft.Xna.Framework.GameComponent
    {
        public Help(Game game): base(game)
        {
           // TODO: Construct any child components here
        }

        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }

        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

            base.Update(gameTime);
        }
    } 
 }


Game is your namespace, just as the error suggests.

namespace Game {

Your attempting to pass in an object also called Game

public Help(Game game)

You either need to change your namespace to be something other than your object name, or fully qualify your object 'Game' if you have an object under another namespace called Game. e.g

public Help(AnotherNamespace.Game game)


You named your namespace "Game" which collides with the built in XNA type, Game. Change Game to Microsoft.Xna.Framework.Game or rename your namespace to something else.


If you are going to use your namespace of Game, then for everytime you want to use the Microsoft.Xna.Framework.Game class, you'll need to specify the full namespace Microsoft.Xna.Framework.


I think your issue is the Game namespace as it is the same as the Game object type and the compiler can't differentiate them. Change the name of the namespace.

0

精彩评论

暂无评论...
验证码 换一张
取 消