【发布时间】:2013-10-20 17:01:10
【问题描述】:
在我做的构造函数中:
mouseState = Mouse.GetState();
var mousePosition = new Point(mouseState.X, mouseState.Y);
然后在我创建的输入法里面添加:
private void ProcessInput(float amount)
{
Vector3 moveVector = new Vector3(0, 0, 0);
KeyboardState keyState = Keyboard.GetState();
if (keyState.IsKeyDown(Keys.Up) || keyState.IsKeyDown(Keys.W))
moveVector += new Vector3(0, 0, -1);
if (keyState.IsKeyDown(Keys.Down) || keyState.IsKeyDown(Keys.S))
moveVector += new Vector3(0, 0, 1);
if (keyState.IsKeyDown(Keys.Right) || keyState.IsKeyDown(Keys.D))
moveVector += new Vector3(1, 0, 0);
if (keyState.IsKeyDown(Keys.Left) || keyState.IsKeyDown(Keys.A))
moveVector += new Vector3(-1, 0, 0);
if (keyState.IsKeyDown(Keys.Q))
moveVector += new Vector3(0, 1, 0);
if (keyState.IsKeyDown(Keys.Z))
moveVector += new Vector3(0, -1, 0);
if (keyState.IsKeyDown(Keys.Escape))
{
this.graphics.PreferredBackBufferWidth = 800;
this.graphics.PreferredBackBufferHeight = 600;
this.graphics.IsFullScreen = false;
this.graphics.ApplyChanges();
}
if (mouseState.LeftButton == ButtonState.Pressed)
{
this.graphics.PreferredBackBufferWidth = 1920;
this.graphics.PreferredBackBufferHeight = 1080;
this.graphics.IsFullScreen = true;
this.graphics.ApplyChanges();
}
AddToCameraPosition(moveVector * amount);
}
我补充说:
if (mouseState.LeftButton == ButtonState.Pressed)
{
this.graphics.PreferredBackBufferWidth = 1920;
this.graphics.PreferredBackBufferHeight = 1080;
this.graphics.IsFullScreen = true;
this.graphics.ApplyChanges();
}
我使用了一个断点,当单击鼠标左键时它什么也不做。
它永远不会进入这个if 块。
它正在到达if,但从未进入它。
那么我该如何让它工作呢? 以及如何使鼠标左键也双击而不是单击?
【问题讨论】:
-
你为什么不在 ProcessInput 方法中调用 Mouse.GetState()?
-
1.618 你是对的。谢谢,我如何使它成为双击鼠标左键而不是单击?