Exception in thread "Thread-1" java.lang.NullPointerException
at java.awt.Rectangle.intersects(Rectangle.java:786)
at Robotron.intersecting(Robotron.java:182)
at Robotron.run(Robotron.java:349)
at java.lang.Thread.run(Thread.java:745)
의 문제점은 여기입니다는 :널 포인터
public void intersecting(Sprite r1, Sprite r2)
{
System.out.println("The grunts isAlive is: "+r1.isAlive+" his xpos is: "+r1.rec.x+" his ypos is: "+r1.rec.y);
if(r1.rec.intersects(r2.rec) && r1.isAlive==true && r2.isAlive==true)
{
r1.isAlive=false;
r2.isAlive=false;
}
}
내 System.out에의 출력은 다음과 같습니다 The grunts isAlive is: true his xpos is: 936 his ypos is: 478
. 하지만 어떤 이유에서 나에게 널 포인터를주는 것
이것이 내 초자연식을 초기화하는 방법이다. 문제는 거기에있는 것일까?
for(int i=0; i<grunt.length;i++)
{
int randX = (int)(Math.random()*worldx);
int randY = (int)(Math.random()*worldy);
if(hero.outerCircle.inCircle(randX,randY)!=true)
{
grunt[i] = new EnemyD4(randX,randY, worldx, worldy, 50,70);
}
if(hero.outerCircle.inCircle(randX,randY)==true)
{
randX+=100;
grunt[i] = new EnemyD4(randX,randY, worldx, worldy, 50,70);
}
}
어떻게'''crossecting()''을 호출합니까? –
null 포인터 예외는 어디에서 발생합니까? – CMPS
하나의 가능한 원인은 스레드와 주 프로그램이 개별적으로 실행되기 때문입니다. 그러나 다시, 문제를 이해하기위한 전체 (주석 처리 된) 코드를 보여주십시오. – Atieh