2
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Shooter
{
class Player
{
//Animation representing player
public Texture2D PlayerTexture;
//Position of player relative to left side of screen
public Vector2 Position;
public bool playerActive;
public int playerHealth;
public int Width
{
get { return PlayerTexture.Width; }
}
public int Height
{
get { return PlayerTexture.Height; }
}
public void Initialize(Texture2D texture, Vector2 position)
{
PlayerTexture = texture;
//sets the position of player to middle of the screen
Position = position;
playerActive = true;
playerHealth = 100;
}
public void Update()
{
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(PlayerTexture, Position, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
}
}
}
내 플레이어 클래스의 코드이며 프로그램에 컴파일 오류가 없습니다. 그러나 게임을 실행하면 "Game1이 응답을 멈췄다"는 메시지가 표시되고 디버깅 할 때 "값이 null이 될 수 없습니다."라는 오류 메시지가 표시됩니다. XNA를 사용하여 Windows 게임 개발을위한 자습서를 다음과 같이 작성합니다.프로그램이 응답하지 않습니다. 디버깅에 '값은 null이 될 수 없습니다.'라고 표시됩니다.
감사합니다.