我有一个bool称为attack
这无论何时按下按钮Q
我设置为true(Q
是攻击),我用的断点,试图解决自己的问题BOOL不更新
。将attack
设置为true的代码行正在运行,但实际上并没有将attack
设置为true ......我是XNA的新手,所以很抱歉,如果这是一个明显的解决方案。下面是代码..:(PS我省略了大量的代码无关的问题)
public class Player
{
Animation playerAnimation = new Animation();
public void Update(GameTime gameTime)
{
keyState = Keyboard.GetState()
if (keyState.IsKeyDown(Keys.Q))
{
tempCurrentFrame.Y = 0;
*** playerAnimation.Attack = true; *** This line of code runs yet doesn't actually work
}
public class Animation
{
bool attack;
public bool Attack
{
get { return attack; }
set { value = attack; }
}
public void Update(GameTime gameTime)
{
if (active)
frameCounter += (int)gameTime.ElapsedGameTime.TotalMilliseconds;
else
frameCounter = 0;
if (attack) ***This never turns true***
switchFrame = 50;
就像我前面说的,我用的断点检查,所有的代码运行,只是我的攻击变量没有发生,我不知道为什么不。
我有一个类似的布尔被称为积极与所有相同的属性和代码链接,但布尔确实得到更新,这就是为什么我如此卡住。
谢谢你的时间。
难以置信,当这是一个明显的错误时,我在其他地方度过了这么多时间。我想这只是随着经验而来。感谢您的时间。 – Ralt 2013-03-07 17:25:32
@Ralt即使经验丰富的程序员也时不时犯错:) – JaredPar 2013-03-07 17:27:04
是的。像这样的错误往往是最难找到的,因为如此简单的事情并不是狩猎的焦点。 – spender 2013-03-07 17:55:09