When lunching the application with DesktopLuncher i experience UnsatisfiedLinkError
on root class (Main) in core module of project.
`public class Main extends Game {
@Override
public void create() {
this.cameraBuilder = ...
setScreen(new LandingMenu(this));
}
@Override
public void render() {
super.render();
}
@Override
public void dispose() {
batch.dispose();
}
public World getWorld() {
return world;
}
public SpriteBatch getBatch() {
return batch;
}
public CameraBuilder<OrthographicCamera> getCameraBuilder() {
return cameraBuilder;
}
private final SpriteBatch batch = new SpriteBatch();;
private CameraBuilder<OrthographicCamera> cameraBuilder;
private final World world = new World(new Vector2(0, -9.8f), true);
}`
any answer will be appreciated.
CodePudding user response:
The exception is a cause and issue lives on create
method on ApplicationListener
Called when the Application is first created, on the other hand SpriteBatch is a Batch which is used for drawing Sprites, more specifically, it deals with drawing a bunch of textures on Quads in OpenGL thus is must be initialized inside of create method and not in the root class level.
@Override
public void create() {
batch = new SpriteBatch();
setScreen(new LandingMenu(this));
}
...
private SpriteBatch batch;
Find more in here.