I am a bit stumped here on why this is not working, it was working before and I can’t remember what I changed lol.
Basically I have a factory method that allows you to create a Physics instance, Physics extends Body and has a bunch of helper methods built in.
However, to create a body you must do the following:
Body body = world.createBody(bd);
But my method returns Physics like so:
public static Physics createPhysics(BodyType type, Vector2 position,
boolean fixedRotation) {
BodyDef bd = new BodyDef();
bd.type = type;
bd.position.set(position);
bd.fixedRotation = fixedRotation;
Body body = world.createBody(bd);
Physics p = (Physics) body;
return p;
}
I can see right away this is not going to work, Body is not an instance of Physics so you can’t cast it. I am not sure what to do here, I can’t create a Physics instance due to the way the Body class is coded, it requires data only the World can provide.
I would like to get this working as it really reduces the amount of lines of code, like getX() and getY() for a start as well as helper methods for changing fixture filter data with 1 line.