-2
我在下面的代码中一直收到这个错误。有人可以告诉我我做了什么错。 foreach语句无法在类型“方法组”的变量操作,因为“法团”不包含公共定义为XNA foreach语句错误
private void updateVelocity(KeyboardState keyboardState)
{
var keysdictionay = new Dictionary<Keys, Vector2>
{
{Keys.Left, new Vector2(-1, 0)},
{Keys.Right, new Vector2(1, 0)},
{Keys.Up, new Vector2(0, -1)},
{Keys.Down, new Vector2(0, 1)}
};
var velocity = Vector2.Zero;
foreach (var keypress in keyboardState.GetPressedKeys)
{
velocity += keysdictionay[keypress];
}
Velocity = velocity * shipspeed;
}
public Vector2 Velocity { get; set; }
float shipspeed = 300.0f;
}
}