我正在YouTube上关注Michiel Wouters的蛇游戏教程,并且“ Keys”枚举不起作用
总是出现此消息:“找不到类型或名称空间名称'type / namespace'(您是否缺少using指令或程序集引用?)”
我确定要引用System.Windows.Forms,并将System.Windows.Forms.dll添加到项目文件夹中
这是我的输入课
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Snake
{
class Input
{
//Load list of available Keyboard buttons
private static Hashtable keyTable = new Hashtable();
//Perform a check to see if a particular button is pressed
public static bool KeyPressed(Keys key)
{
if (keyTable[key] == null)
{
return false;
}
return (bool)keyTable[key];
}
//Detect if a keyboard button is pressed
public static void ChangeState(Keys key, bool state)
{
keyTable[key] = state;
}
}
}