Note that there are some explanatory texts on larger screens.

plurals
  1. POChecking Keyboard moving wrong list
    primarykey
    data
    text
    <p>When I am trying to move to a different item in one list it changes items in a different list instead, can't figure it out. When I get it to move the first list, then when I try to click enter to try to have it switch lists, it does nothing. Here's the code:</p> <pre><code> public void Update(GameTime gameTime, Game1 game) { keyboard = Keyboard.GetState(); mouse = Mouse.GetState(); //Checks if the up arrow has been pressed and released if (CheckKeyboard(Keys.Up)) { if (Selected.Equals("None")) { if (selected &gt; 0) selected--; else selected = (buttonList.Count - 1); } else if (Selected.Equals("Play")) { } else if (Selected.Equals("LevelSelect")) { //This is what is meant to happen while sChapter1 = 0 but the error is it is //moving one of the other lists if (sChapter1 == 0) { if (sChapter &gt; 0) sChapter--; else sChapter = (chapterList.Count - 1); } //This is what should happen when enter is pressed on the first chapter else if (sChapter1 == 1) { if (sC1Level &gt; 0) sC1Level--; else sC1Level = (c1LevelList.Count - 1); } //This is what should happen when enter is pressed on the second chapter else if (sChapter1 == 2) { if (sC2Level &gt; 0) sC2Level--; else sC2Level = (c2LevelList.Count - 1); } //This is what should happen when enter is pressed on the third chapter else if (sChapter1 == 3) { if (sC3Level &gt; 0) sC3Level--; else sC3Level = (c3LevelList.Count - 1); } } } //Checks if the down arrow is pressed and released if (CheckKeyboard(Keys.Down)) { if (Selected.Equals("None")) { if (selected &lt; buttonList.Count - 1) selected++; else selected = 0; } else if (Selected.Equals("Play")) { } else if (Selected.Equals("LevelSelect")) { //This is what is meant to happen while sChapter1 = 0 but the error is it is //moving one of the other lists if (sChapter1 == 0) { if (sChapter &lt; chapterList.Count - 1) sChapter++; else sChapter = 0; } //This is what should happen when enter is pressed on the first chapter key else if (sChapter1 == 1) { if (sC1Level &lt; c1LevelList.Count - 1) sC1Level++; else sC1Level = 0; } //This is what should happen when enter is pressed on the second chapter else if (sChapter1 == 2) { if (sC2Level &lt; c2LevelList.Count - 1) sC2Level++; else sC2Level = 0; } //This is what should happen when enter is pressed on the third chapter else if (sChapter1 == 3) { if (sC3Level &lt; c3LevelList.Count - 1) sC3Level++; else sC3Level = 0; } } } if (CheckKeyboard(Keys.Enter)) { //Checks if the selected item is a certain one in the list to //cause something to happen. if (selected == buttonList.Count - 1) Game1.GameState = "Menu"; //Sets it to draw the LevelSelect portion of the menu if (selected == buttonList.Count - 2) Selected = "LevelSelect"; if (selected == buttonList.Count - 3) Selected = "Play"; //Checks what chapter of the games it is on so that it can choose levels within the //chapter. This should only effect when a chapter is selected and enter is pressed //but it is effecting whether the chapterlist is being scrolled thru or if the //levellists are. if (sChapter == chapterList.Count - 1) sChapter1 = 3; if (sChapter == chapterList.Count - 2) sChapter1 = 2; if (sChapter == chapterList.Count - 3) sChapter1 = 1; } if (CheckKeyboard(Keys.Back)) { //Ignore this, it hasn't been used yet } prevMouse = mouse; prevKeyboard = keyboard; } public bool CheckKeyboard(Keys key) { //Checks if the key has been pressed and released return (keyboard.IsKeyUp(key) &amp;&amp; prevKeyboard.IsKeyDown(key)); } </code></pre> <p>Note: I figure out what the problem is, in my CheckKeyboard(Keys.Enter) it is doing both at the same time. So it is jumping over a list, I've tried putting the thread to sleep but its still doing it, any suggestions?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload