Hello and welcome to our community! Is this your first visit?
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
    Thanked 0 Times in 0 Posts

    Changing x-value while holding key down

    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
    Saskatoon, Saskatchewan
    Thanked 2,662 Times in 2,631 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'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • 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