我在XNA中有一些鼠标坐标的问题-0x0任意接近(但不在)屏幕左上角。
我现在以窗口模式运行游戏,但是坐标是基于屏幕而非游戏窗口的(尽管XNA文档告诉我应该相反)。
提前感谢您!
以下是代码:
我现在以窗口模式运行游戏,但是坐标是基于屏幕而非游戏窗口的(尽管XNA文档告诉我应该相反)。
提前感谢您!
以下是代码:
namespace TheGame
{
class Mousey
{
static public Vector2 pos;
static private Texture2D tex;
static public MouseState mouseState;
static public MouseState previousState;
//static public Mousey()
//{
//}
static public void Update()
{
previousState = mouseState;
mouseState = Mouse.GetState(); //Needed to find the most current mouse states.
pos.X = mouseState.X; //Change x pos to mouseX
pos.Y = mouseState.Y; //Change y pos to mouseY
}
//Drawing function to be called in the main Draw function.
static public void LoadContent(ContentManager thecontent)
{
tex = thecontent.Load<Texture2D>("mousey");
}
static public void Draw(SpriteBatch batch) //SpriteBatch to use.
{
batch.Draw(tex, pos, Color.White); //Draw it using the batch.
}
static public bool LBP()
{
if (mouseState.LeftButton == ButtonState.Pressed && previousState.LeftButton == ButtonState.Released)
{
return true;
}
else
{
return false;
}
}
}
}