Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So in my little side scroller java game I'm attempting to make collision for my character against walls. I am using keybindings instead of key listeners because of the focusing issues it often caused. Here's the code I'm having trouble with:

 Action moveleft = new AbstractAction(){
      public void actionPerformed(ActionEvent e)
      {
          if (moving==true&&offsetX!=2){
              offsetX=offsetX+2;
          }
      }
    };

The problem is that when a key is held down to make the character move, in the actionperformed method, it doesn't recheck the conditional statement that determines whether moving is true or false when the key is held down. This results in the character moving indefinitely through all walls until the key is released. So why is this? What can I do to remedy it? If any more code is required from my program I can provide! Thanks!

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.