Quantcast
Channel: Ajuda no metodo Content.Load
Viewing all articles
Browse latest Browse all 2

Ajuda no metodo Content.Load

0
0

Olá a todos,

Meu problema é o seguinte:

Eu tenho uma classe chamado Player.cs que tem esse metodo

public void Initialize(Texture2D texture, Vector2 position)
        {
            PlayerTexture = texture;           
            Position = position;
            Active = true;
            Health = 100;
        }

Na classe Game1.cs no metodo protected override void LoadContent() eu coloquei assim:

           {         
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y+
                                                GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
            player.Initialize(Content.Load<Texture2D>("player"), playerPosition);
        }

Quando eu tento rodar eu recebo a mensagem Object reference not set to an instance of an object. apontando para essa linhaplayer.Initialize(Content.Load<Texture2D>("player"), playerPosition);

Já tentei colocar @"Content\player",mas quando eu faço isso, o VS diz que o arquivo não foi encontrado.

Detalhe: No scopo da classe game1.cs eu coloquei Player player e no metodoInitialize() eu coloquei player = new Player


Desde já agradeço :)


We may be human, but we're still animals


Viewing all articles
Browse latest Browse all 2

Latest Images





Latest Images