本文介绍了我如何使用console.keyavailable。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检测是否有任何按键被按下,但据我所知,if语句没有被触发。
工作是正在打印,因此正在调用GameLoop()。
不确定该怎么做...感谢您的帮助!
我尝试过:
I am wanting to detect if any key is being pressed but as far as I can tell the if statement isn't being triggered.
"working" is being printed so GameLoop() is being called.
Not sure what to do.. Thanks for the help!
What I have tried:
public static int GameLoop()
{
while(true)
{
if(Console.KeyAvailable == true)
{
Environment.Exit(0); //test to see if being used
Player.KeyPressed = Console.ReadKey().KeyChar;
Player.Movement();
}
Console.WriteLine("working");
推荐答案
这篇关于我如何使用console.keyavailable。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!