Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2010
    Rep Power

    Question Multiple keys pressed, diagonal movement

    I'm trying to make the character in my game move diagonal, i'm able to make him move diagonal, but i can't make so that if you press Left && Up the UpLeft method gets called..

    What i want to know is how do i make so that java accept multiple keys pressed.. my current alternative is to have buttons like q for up, left and e for up, right and so on..

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Colombo, Sri Lanka
    Blog Entries
    Rep Power

  3. #3
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Zurich, Switzerland
    Rep Power


    you can register an action listener to each key you want. read this tutorial and you will know how. in games usually only the keys A, S, D and W are used to move. so to move diagonally you must "look" in that direction and then press W.
    Last edited by j2me64; 03-02-2011 at 10:43 AM.

Similar Threads

  1. Key/mouse movement
    By falkon114 in forum New To Java
    Replies: 3
    Last Post: 02-21-2011, 03:12 AM
  2. Handling input - multiple keys pressed
    By Shadowstrike in forum Advanced Java
    Replies: 3
    Last Post: 12-30-2010, 02:47 PM
  3. Checking for multiple keys pressed
    By MagnusLarsen in forum New To Java
    Replies: 15
    Last Post: 08-22-2010, 11:51 AM
  4. data structure with multiple keys
    By jon80 in forum New To Java
    Replies: 2
    Last Post: 06-13-2009, 03:02 PM
  5. Movement of balls
    By BlitzA in forum New To Java
    Replies: 8
    Last Post: 01-09-2008, 04:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts