1

ゲームのコントロールの編集に大きな問題があります。ゲーム内ボタンがあり、それをクリックしたときです。「Choose your key..」というテキストが表示されるが、実際の設定方法がわからない..

「入力待ち」ブールを作成しました..これは本当のコードではありません。私が想像する方法です

if (buttonIsClicked) waitinForInput = true;

while(waitingForInput)
{
kbState = Keyboard.GetState();
somehow convert it to Keys.(STH);
if (Keys.STH != defaultKeys)
{
defaultKeys = Keys.STH;
waitingForInput = false;
}
}

これを行う方法はありますか..できるだけ簡単ですか? そして、私の悪い英語でごめんなさい..これは私の母国語ではなく、急いで作成しました..

助けてくれてありがとう.. :-)

4

1 に答える 1

0

このようなもの:

 KeyboardState currentKeyboardState = new KeyBoardState();
 KeyboardState previousKeyboardState = new KeyBoardState();

 Keys jumpKey = Keys.Space;

 public void handleInput()
 {
     lastKeyboardState = currentKeyboardState;

     currentKeyboardState = Keyboard.GetState(PlayerIndex.One);

     bool waitingForKey = false;

     if(currentKeyboardState.IsKeyDown(Keys.A) && waitingForKey == false)
     {
         waitingForKey = true;            
     }

     if(waitingForKey == true)
     {
          //currentKeyboardState.GetPressedKeys() returns a list of pressed keys,
          //So, currentKeyboardState.GetPressedKeys()[0] returns the first pressed key

          if(currentKeyboardState.GetPressedKeys().Count() > 0)
          {
            jumpKey = currentKeyboardState.GetPressedKeys()[0];
            waitingForKey = false;
          }
     }
 }
于 2013-04-10T20:26:01.380 に答える