Thursday, 12 September 2013

EXCEPTION_ACCESS_VIOLATION - Java Game

EXCEPTION_ACCESS_VIOLATION - Java Game

I get the following error when running my game:

This error occurs when I create an instance of a class called Portal_Sign.
Typically I use the following code: game.stage.addActor((Actor)
con.newInstance(parameters)); I retrieved the "con" object from
Class.class.getConstructor(), which means I'm using reflection to
instantiate objects(Because I could be constructing any of many objects,
each with reasonably similar constructors).
I know I'm only getting the error when the Portal_Sign is being created.
If I change the values in the Vector2 that represents location to new
Vector2(1,1) I don't get a problem. The same applies for
(0,0),(0,1),(1,0),(0,-1),(-1,0),and (-1,-1), or any values that are
greater than or equal to -1 and less than or equal to +1.
if(c.getSimpleName().equals(Portal_Sign.class.getSimpleName())){
game.stage.addActor(new Portal_Sign(game,new
Vector2(2,1),0,0,"asdf|ASDF"));
}else{
game.stage.addActor((Actor) con.newInstance(parameters));
}
If I create 2 Portal_Signs the error goes away.
Here is some source code:
http://hobogames.atspace.cc/TEMPFORERROR/LevelManager.java (Relevant code
is in the try/catch at the bottom of the load method)
http://hobogames.atspace.cc/TEMPFORERROR/Portal_Sign.java
http://hobogames.atspace.cc/TEMPFORERROR/packs.level The file being
loaded. Note, the version uploaded DOES NOT cause error because it creates
2 signs. HOWEVER, if you remove the last
line(Portal_Sign(4,1,0,0,"Baddies|0/32");), you do get the listed error.
http://hobogames.atspace.cc/TEMPFORERROR/Solid.java The highest parent of
Portal_Sign, deals with Libgdx and box2D physics stuff, and the location.
I don't understand why I am getting this issue, any tips would be great,
please help. If you want anything else from me just ask for it.

No comments:

Post a Comment