I have a picture of a little stick figure man and i want to make it appear as if he is jumping.
The code I have to do that is this:
switch(e.getKeyCode()){
case KeyEvent.VK_UP:
for(int i=0; i<=10; i=i+1){
y = y+1; //the int y represents the images position of the y-axis
repaint();
try{Thread.sleep(200);}
catch(InterruptedException ie){}
if(i == 10){
for(int j=0; j<=10; j=j+1){
y = y-1;
repaint();
try{Thread.sleep(200);}
catch(InterruptedException ie){}
}
break;
}
}
break;
but for some reason the image just stays in one place and does not have the jumping effect I wanted.
(proabably has to do with the Thread.sleep(200); method I called, but I dont know how to fix it).
Thanks in advance!