0
\$\begingroup\$

I have the following in my update funtion. The first input for key_enter when textPos!=2 works fine, but the one when textPos==2 doesn't work. The key up and down work fine though.

The System.out.println("Enter: " + choice); never gets printed

public void update() {
        Input input = gc.getInput();
        if (input.isKeyPressed(Input.KEY_ENTER)) {
            if (textShowing && textPos != 2) {
                textPos++;
                textShowing = false;
            }
        }
        if (textShowing && textPos == 2) {
            if (input.isKeyPressed(Input.KEY_ENTER)) {
                System.out.println("Enter: " + choice);
                if (choice == 0) {

                } else if (choice == 1) {

                } else {
                    textPos++;
                    textShowing = false;
                    System.out.println("Text Pos: " + textPos);
                }
            } else if (input.isKeyPressed(Input.KEY_UP)) {
                if (choice > 0) {
                    choice--;
                }
            } else if (input.isKeyPressed(Input.KEY_DOWN)) {
                if (choice < 2) {
                    choice++;
                }
            }
        }
    }
\$\endgroup\$
4
  • \$\begingroup\$ Have you tried attaching the debugger? Set a break point, check your variable values. Pay special attention to textShowing and the value of textPos. \$\endgroup\$
    – House
    Apr 25, 2014 at 15:57
  • \$\begingroup\$ Figured it out. If i switch the "if (input.isKeyPressed(Input.KEY_ENTER))" and "if (textShowing && textPos != 2) {" the other way around it works \$\endgroup\$ Apr 25, 2014 at 16:03
  • \$\begingroup\$ You might want to enter that as an answer to this post, and mark it answered :) \$\endgroup\$ Apr 26, 2014 at 8:07
  • \$\begingroup\$ Wouldn't let me answer it yesterday as I didn't have enough rep \$\endgroup\$ Apr 26, 2014 at 9:47

1 Answer 1

0
\$\begingroup\$

Figured it out. If i switch the "if (input.isKeyPressed(Input.KEY_ENTER))" and "if (textShowing && textPos != 2) {" the other way around it works

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .