Ciao a tutti ,qualcuno sa come far ripetere all infinito il movimento dall alto al basso(e non viceversa) delle immagini??? P.S se avete bisogno posto anche le altre classi.
codice:
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Characters extends Thread {
private int x;
private int y;
private JPanel frame;
private Image im;
public Characters(int a,int b) {
x = a;
y = b;
}
public Characters(int i, int j, JPanel frame,String path) {
this(i,j);
this.frame = frame;
im = Toolkit.getDefaultToolkit().getImage (path);
}
@Override
public void run() {
for (int i = 0; i < 24; i = i + 1) {
y += i;
try {
Thread.sleep(200,i);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void draw(Graphics graphics){
graphics.setColor(Color.BLACK);
//qui metti l imagel
//graphics.drawImage(.....)
graphics.drawImage(im, x, y,frame);
}
}