hallo,
ich versuche mich an meinem ersten spiel. ein ball soll erstmal hin und her fliegen und wenn man auf ihn klickt soll er auch die richtung wechseln. eclipse streicht mir "Event" an mit dem Kommentar: "cannot be resolved to a type"
ich hatte diese methode aber vorher schonmal wo drin und das hat funktioniert,... komisch.
ich versuche mich an meinem ersten spiel. ein ball soll erstmal hin und her fliegen und wenn man auf ihn klickt soll er auch die richtung wechseln. eclipse streicht mir "Event" an mit dem Kommentar: "cannot be resolved to a type"
ich hatte diese methode aber vorher schonmal wo drin und das hat funktioniert,... komisch.
Code:
package spiel;
import java.applet.*;
import java.awt.Graphics;
public class Main extends Applet implements Runnable {
private Ball ball1;
public void start(){
Thread th=new Thread(this);
th.start();
}
public void init(){
ball1=new Ball();
}
public boolean mouseDown (Event e, int x, int y)
{
if(ball1.getroffen(x, y)){
ball1.setGeschwindigkeitX(-(ball1.getGeschwindigkeitX()));
}
return true;
}
public void run ()
{
while(true){
ball1.bewege();
repaint();
try{
Thread.sleep(10);
}
catch (InterruptedException ex){
}
}
}
public void paint(Graphics g){
g.fillOval(ball1.getPositionX()- ball1.getRadius(), ball1.getPositionY() - ball1.getRadius(), 2 * ball1.getRadius(), 2 * ball1.getRadius());
}
}