thanks for dropping over.
I got 2 issues with Box2DLights.
The first one isn't that important to solve, the second, however,
I got multiple PointLights that follow a porjectile. So every porjectile has an ArrayList with all the PointLights it needs in it. When the porjectile hits an object all the Lights should get disposed. Apparently that´s a problem.
if(hit){
deleted = true;
for(int i = 0; i<myLight.size();i++){
myLight.get(i).dispose();
}
}
This causes a Fatal Exeption
A fatal error has been detected by the Java Runtime Environment: EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffc6fc59f58, pid=6944, tid=6676 JRE version: Java(TM) SE Runtime Environment (8.0_45-b15) (build 1.8.0_45-b15) Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode windows-amd64 compressed oops) Problematic frame: C [ntdll.dll+0x39f58] Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
The problem, I guess, is that a disposed object somehow cant be referenced anymore by the ArrayList. The question is how to do this better.
When adding a ConeLight to my game
playerLight = new ConeLight(this,100,Color.WHITE,100,1920f/2f,1080f/2f,0,60);
//used "this" because I called this method in a class that extends RayHandler
my game just freezes in the Main Menu when pressing "Play" the MainMenu Screen just freezes and a little window appears that says:
"Java(TM) SE binary doesn't work anymore"
PointLight, howeever, works perfectly. I honestly have no clue and whether this is my fault or a bug.
I have solved it, FINALLY. It was a pretty dumb mistake:
As I dont really need a World object, the RayHandler constructor, however, does, I created a World gave it the rayhandler and disposed it afterwards. Stupid, I know. So instead of
public void create(){
....
World world = new World(new Vector2(0,0),false);
rayHandler = new RayHandler(world);
world.dispose;
}
You need to move world.dispose to the dispose method and make world a field.
public void create(){
....
world = new World(new Vector2(0,0),false);
rayHandler = new RayHandler(world);
}
...
public void dispose(){
...
rayHandler.dispose;
world.dispose();
}