|
-
keyup, keydown
We're am currently tinkering with Mike Hall's old Asteroid code and we're trying to take out the deprecations and we ran into a few problems.
We could not fix the keyUp and keyDown deprecations. Our code for keyUp was:
public boolean keyUp(Event e, int key) {
// Check if any cursor keys where released and set flags.
if (key == Event.LEFT)
left = false;
if (key == Event.RIGHT)
right = false;
if (key == Event.UP)
up = false;
if (key == Event.DOWN)
down = false;
if (!up && !down && thrustersPlaying) {
thrustersSound.stop();
thrustersPlaying = false;
}
return true;
}
When we try and change keyUp to something else, you cannot press a button more than once while running the program.
The code for keyDown is:
public boolean keyDown(Event e, int key) {
// Check if any cursor keys have been pressed and set flags.
if (key == Event.LEFT)
left = true;
if (key == Event.RIGHT)
right = true;
if (key == Event.UP)
up = true;
if (key == Event.DOWN)
down = true;
if ((up || down) && ship.active && !thrustersPlaying) {
if (sound && !paused)
thrustersSound.loop();
thrustersPlaying = true;
}
When we try and change keyDown, the program won't even start.
Can anyone help us?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks