Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2010
    Posts
    95
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Changing x-value while holding key down

    Hi
    How do I increase the x-value by 20/sec while holding down the upper-key? If I have been holding the upper-key down for 5 sec the x-value should be 100 if initial x-value is 0.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    By implementing the KeyListener interface or extending the KeyAdapter.
    I think the keyPressed event fires until it reaches the keyReleased, and if it doesn't continually fire it doesn't matter since you can simply use KeyPressed as a start, and keyReleased as an end. Tie that in with a variable to listen to them, or using a thread and it can constantly update the variable for you.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    earni23 (11-13-2010)


  •  

    Posting Permissions

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