Hallo liebe Community,
ich habe folgendes Problem:
So sieht meine Klasse aus und
Ich habe Windows 8 64-Bit, und benutze die Programmierumgebung Eclipse.
Hier ist die Klasse MovableImage, falls die weiterhilft:
Ich nehme an, dass Eclipse den Pfad der Bilder nicht findet. Die Bilder liegen in
Danke schon mal im Voraus für die Antworten .
ich habe folgendes Problem:
Java:
package animationGame;
class AnimationPanel extends SimpleAnimation {
@Override public void doOnTick() {
move();
doChecks();
repaint();
}
public void doChecks(){
for(GameObject g1:gos)
for(GameObject g2:gos)
if(g1 != g2 && g1.touches(g2))
reactWhenTouching(g1,g2);
}
void reactWhenTouching(GameObject g1,GameObject g2) {
g1.turn(); g1.move();
g2.turn(); g2.move();
}
public static void main(String [] args) {
MovablePanel p = new AnimationPanel();
p.gos.add(new MovableImage("ausrufe.png",0,0,1,1));
p.gos.add(new MovableImage("info.png",200,200,-1,-1));
ShowInFrame.show(p);
}
}
so die Fehlermeldung.Fehlermeldung hat gesagt.:Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at animationGame.GeometricImage.<init>(GeometricImage.java:10)
at animationGame.MovableImage.<init>(MovableImage.java:14)
at animationGame.AnimationPanel.main(AnimationPanel.java:20)
Ich habe Windows 8 64-Bit, und benutze die Programmierumgebung Eclipse.
Hier ist die Klasse MovableImage, falls die weiterhilft:
Java:
package animationGame;
import javax.swing.*;
class MovableImage extends GeometricImage implements GameObject {
Vertex deltaPos = new Vertex(0,0);
public Vertex getDeltaPos() {return deltaPos;}
public void setDeltaPos(Vertex v) {deltaPos = v;}
public MovableImage(String name, double x, double y) {
super(name, x, y);
}
public MovableImage(String name, double x, double y, double dX, double dY) {
super(name, x, y);
deltaPos = new Vertex(dX, dY);
}
public MovableImage(ImageIcon icon, double x, double y, double dX, double dY) {
super(icon, x, y);
deltaPos = new Vertex(dX, dY);
}
public void move() {pos.addMod(deltaPos);}
public void turn() {deltaPos.skalarMultMod(-1);}
public boolean isLeftOf(GameObject that) {
return this.getPos().x + this.getWidth() < that.getPos().x;
}
public boolean isAbove(GameObject that) {
return this.getPos().y + this.getHeight() < that.getPos().y;
}
public boolean touches(GameObject that) {
if(this.isLeftOf(that)) return false;
if(that.isLeftOf(this)) return false;
if(this.isAbove(that)) return false;
if(that.isAbove(this)) return false;
return true;
}
public boolean isLargerThan(GameObject that) {
return getWidth() * getHeight() > that.getWidth() * that.getHeight();
}
}
der Workspace inPfad hat gesagt.:D:\Eclipse\projects\Java will nur spielen
Ich habe dieses Thema schon einmal erstellt, doch dieser blieb ca. 5 Monate lang unberührt, sodass er gelöscht wurde. Dabei kamen einige Antworten, doch keine von diesen löste das Problem.Pfad hat gesagt.:D:\Eclipse\projects
Danke schon mal im Voraus für die Antworten .
Zuletzt bearbeitet: