Results 1 to 5 of 5
- 06-03-2010, 09:13 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
why does this code keep freezing?
public boolean keyDown (Event e, int key)
{
while (key == Event.LEFT)
{
if (key != Event.LEFT)
{
x_speed = 0;
continue;
}
x_speed = -1;
}
while (key == Event.RIGHT)
{
if (key != Event.RIGHT)
{
x_speed = 0;
continue;
}
x_speed = 1;
}
return true;
}Last edited by berkeley; 06-03-2010 at 10:50 AM.
- 06-03-2010, 09:47 AM #2
there is something wrong inside the while(true) loop. test the results inside the loop in the console before you run it as an applet.
- 06-03-2010, 10:11 AM #3
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
There is nothing wrong with that loop because it works when I don't have the other two whiles loops
- 06-03-2010, 04:15 PM #4
How do you know that the code you posted is "freezing"?
Add some println() as debug to show where and what is happening.
Or just use paper and pencil to walk thru/desk check what happens in the code.
- 06-03-2010, 04:41 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
can any one pls send me a sample code for calling a jsp code in swings
By sniffer139 in forum AWT / SwingReplies: 1Last Post: 03-04-2010, 11:19 AM -
Convert java code to midlet code
By coldvoice05 in forum Advanced JavaReplies: 1Last Post: 08-09-2009, 01:21 PM -
Application freezing and recovering with Strange behaviour found in Thread Dump & GC
By Rajin Das in forum Advanced JavaReplies: 2Last Post: 03-16-2009, 02:33 PM -
freezing when use socket.accept() inside of a thread
By tamayo in forum Advanced JavaReplies: 0Last Post: 07-23-2007, 11:48 PM -
Generating Code Automatically Using Custom code Template In Eclipse
By JavaForums in forum EclipseReplies: 1Last Post: 04-26-2007, 03:52 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks