【发布时间】:2017-01-29 06:10:11
【问题描述】:
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 已停止响应”,当我调试时,出现一条错误消息,提示“值不能为空”。我在这里学习使用 XNA 开发 Windows 游戏的教程:
谢谢!
【问题讨论】: