Hi, me again Q.Q
I got a BUTTLOAD of errors, when i tried to use the ppc, instead of intersect()
this is what i wrote:
It says Nullpointer exception at line 10 and 23
And also, actor not in world at line 22. How can this be? I made the requirement to only call edge() when getObjects() isn't null, so why does it still call the method?
Regarding hit++; , the hit value is used by my sm class. and this class extends it
Edit: Actually, ive got a lot more nullpointer exceptions, shall i post them all, or can you already see, what i did wrong?
Edit2: Come to think about it, since i wrote if( list() != null), how comes i get error, before my bullet even touches anything?
public void act() { int x = getX(); int y = getY(); move(30.0); if(list() != null) { if( hit < 5) { hit++; getWorld().removeObject(this); } else { getWorld().removeObject(list()); getWorld().removeObject(this); } } if(getWorld().getObjects(fb.class) != null) { if(edge()) { getWorld().removeObject(this); } } } private boolean edge() { if(getX() < 10 || getX() > getWorld().getWidth() - 10) return true; if(getY() < 10 || getY() > getWorld().getHeight() - 10) return true; else return false; } public Actor list() { List<Actor> list = getWorld().getObjects(sm.class), list2 = new ArrayList(); for(Actor A : list) if(intersects(A)&&touch(A)) return A; return null; } }