Press and hold Dpad direction doesn't generate continuous events

by ron » Sat, 27 Dec 2008 07:03:31 GMT

Sponsored Links

I am thinking to write a game that uses the Dpad as the direction
keys. I am expecting to press and hold the Dpad's up/down/left/right
to control my game character to move in those directions. However,
when I test it on the emulator, pressing the Dpad right will first
generate 1 onKeyDown event, then it wait for a long while (~2 seconds)
before generate successive key events.. that's not good for me since
my character will move one step and stop (the first event), then wait
for a second or 2 and it continue to move.

Anyone has any idea why it happens and anyway to work around it??



Press and hold Dpad direction doesn't generate continuous events

by » Tue, 30 Dec 2008 03:13:14 GMT

 Couple of points:
You shouldn't really be relying on the keyboard repeat in a game. Set
a flag on the keydown, and clear it on the keyup. Check the flag
periodically (in the main game loop or via a timer) to see what keys
are currently held down and act accordingly.
No devices have dpads yet. The G1 has a trackball that sends dpad
style keypress events, but it's no way usable for games (though it
would be interesting to see it used as a real trackball - centipede
anybody?!) Make sure you also allow an alternative keyboard control
scheme (WSAD perhaps, although a bit close to G1's menu key).


Sponsored Links

Other Threads

1. Preparing two MediaRecorder or MediaPlayer instances simultaneously


I'm trying to develop an app for live video streaming from a server on
one phone to a client on another.

For this, on server, I capture videos of 10secs duration,send the file
to client while i reset MediaRecorder to continue capturing and write
to a different file and so on.

I've figured out that once a MediaRecorder is stopped,it can't be
started again without calling prepare() and i believe prepare takes a
very long time which introduces a considerable delay between two

So I thought if I could prepare one MediaRecorder instance while
another is capturing then I could start this instance as soon as the
first one stops,which would reduce the delay. I also created 2
SurfaceView objects and gave each MediaRecorder a different holder of
the two SurfaceViews.But when i tried this,the application just
crashed and closed.

Is there no way i can do this? Also,preparing two MediaPlayer
instances simultaneously is not allowed?


2. How to export contacts in sqlite

Hi, my question is if there are any way to export the contacts of your
phone usin contactscontract in a sqlite file to the SD or if anyone
know a guide in the new contactscontract API


3. debug messages on stdout

4. Hello Views GridView Tutorial - Android Packaging Problem

5. proxy tool

6. Run binary application from android source code and get stdout - problem permission denied

7. Android Widget Binder Transaction