I'm coding a program to move a player on the screen,
but the program directly run to the end,
the animation part dose not display,
how can i modify my code to show the movement of the player?
here is the run function,
Thread t, w;
public void run() {
while (isClick) {
try {
repaint();
t.sleep(500);
int j = playerStep + 40;
while(playerStep < j) {
try {
playerStep += 10;
repaint();
w.sleep(300);
} catch (InterruptedException err) {
JOptionPane.showMessageDialog(null, "Moving error!");
}
}
} catch (InterruptedException err) {
JOptionPane.showMessageDialog(null, "Drawing error!");
}
isClick = false;
repaint();
}
}
Thanks a lot.