java - libgdx not initialized yet -


i have been coding libgdx application (for desktop only) while , after deciding cleanup code part part iv'e gotten problem cant seem solve myself..

exception:

exception in thread "lwjgl application" com.badlogic.gdx.utils.gdxruntimeexception: java.lang.unsatisfiedlinkerror: com.badlogic.gdx.physics.box2d.polygonshape.newpolygonshape()j     @ com.badlogic.gdx.backends.lwjgl.lwjglapplication$1.run(lwjglapplication.java:131) caused by: java.lang.unsatisfiedlinkerror: com.badlogic.gdx.physics.box2d.polygonshape.newpolygonshape()j     @ com.badlogic.gdx.physics.box2d.polygonshape.newpolygonshape(native method)     @ com.badlogic.gdx.physics.box2d.polygonshape.<init>(polygonshape.java:29)     @ com.mygdx.game.handler.bodyeditorloader.<init>(bodyeditorloader.java:41)     @ com.mygdx.game.util.gameutils.init(gameutils.java:23)     @ com.mygdx.game.dungeonlife.create(dungeonlife.java:168)     @ com.badlogic.gdx.backends.lwjgl.lwjglapplication.mainloop(lwjglapplication.java:147)     @ com.badlogic.gdx.backends.lwjgl.lwjglapplication$1.run(lwjglapplication.java:124) 

after googling while figured error mentioned in this thread in

another problem might instantiate spritebatch (or else internally uses spritebatch) (looked bit in stacktrace).

but answer mentions

instead, create such things in create/show methods of game.

i cant seem understand when libgdx initialized , ready use, , place gameutils.init() method assure libgdx initialized

my code follows: (i have taken out e-relevant methods)

application class

package com.mygdx.game;  import box2dlight.rayhandler; import com.badlogic.gdx.applicationadapter; import com.badlogic.gdx.gdx; import com.badlogic.gdx.graphics.color; import com.badlogic.gdx.graphics.gl20; import com.badlogic.gdx.graphics.orthographiccamera; import com.badlogic.gdx.graphics.texture; import com.badlogic.gdx.graphics.g2d.textureregion; import com.badlogic.gdx.maps.mapproperties; import com.badlogic.gdx.maps.tiled.tiledmap; import com.badlogic.gdx.maps.tiled.tmxmaploader; import com.badlogic.gdx.maps.tiled.renderers.orthogonaltiledmaprenderer; import com.badlogic.gdx.math.vector2; import com.badlogic.gdx.physics.box2d.*; import com.mygdx.game.entity.mobentity; import com.mygdx.game.entity.physicalentity; import com.mygdx.game.entity.player; import com.mygdx.game.entity.weapon; import com.mygdx.game.handler.*; import com.mygdx.game.util.collisionconstants; import com.mygdx.game.util.gameutils; import com.mygdx.game.util.tileobjectutil; import com.mygdx.game.util.worldconstants; import com.mygdx.game.valtype.weapondefinition;  public class dungeonlife extends applicationadapter implements worldconstants {      orthographiccamera camera;      float width , height;      texture texture;     textureregion[] enttex;      //temp     mobentity demo;      player theplayer;     playerinputprocessor playerinputprocessor;      screenui ui;      int mapwidth , mapheight;      //========================================     gamemap gamemap;     //========================================       @override     public void create () {          texture = new texture("maps/img/tileset_entity.png");          enttex = new textureregion[(int) ((texture.getwidth()*texture.getheight()) / (block*block))];          enttex[0] = new textureregion(texture , 0 , 0 , (int)block , (int)block);         enttex[1] = new textureregion(texture , (int)block , 0 , (int)block , (int)block);          width = gdx.graphics.getwidth()/5;         height = gdx.graphics.getheight()/5;         camera = new orthographiccamera(width,height);         camera.position.set(width / 2, height / 2, 0);          camera.update();          gameutils.init(); // <------this guy          //init();       } ... 

gameutils

package com.mygdx.game.util;  import com.badlogic.gdx.gdx; import com.badlogic.gdx.graphics.texture; import com.badlogic.gdx.graphics.glutils.shaperenderer; import com.badlogic.gdx.maps.tiled.tiledmap; import com.badlogic.gdx.maps.tiled.tmxmaploader; import com.badlogic.gdx.physics.box2d.body; import com.badlogic.gdx.physics.box2d.world; import com.mygdx.game.entity.physicalentity; import com.mygdx.game.handler.*;  import java.util.priorityqueue;  public class gameutils {      public static void init(){          weapon_bodyeditorloader = new bodyeditorloader(gdx.files.internal("textures/weapons/dungeonlife_weapons.json"));         resourcemanager = new resourcemanager();         resourcemanager.addres("friendlyhealth" , new texture("textures/ui/friendlyhealth.png"));         resourcemanager.addres("enemyhealth" , new texture("textures/ui/enemyhealth.png"));         tmxmaploader = new tmxmaploader();         gamecontactlistender = new gamecontactlistender();       }       //global     public static bodyeditorloader weapon_bodyeditorloader;     public static gamecontactlistender gamecontactlistender;     public static resourcemanager resourcemanager;     public static tmxmaploader tmxmaploader;       //currents ============================      public static gamemap current_gamemap;  } 

desktop launcher (the usual)

package com.mygdx.game.desktop;  import com.badlogic.gdx.backends.lwjgl.lwjglapplication; import com.badlogic.gdx.backends.lwjgl.lwjglapplicationconfiguration; import com.mygdx.game.dungeonlife; import com.mygdx.game.util.gameutils;  public class desktoplauncher {     public static void main (string[] arg) {         lwjglapplicationconfiguration config = new lwjglapplicationconfiguration();         config.usegl30 = false;         config.width=640;         config.height=360;         dungeonlife dungeonlife = new dungeonlife();         new lwjglapplication(dungeonlife, config);     } } 

help appriciated! :d

as i've wrote in other linked answer, make sure project correctly set up. box2d extension , needs own native libraries able run.

it seems it's specific problem box2d natives not loaded yet. not loaded automatically when libgdx initializing, have trigger (see wiki).

the code you've posted looks correct, before can use box2d related, have call box2d.init(). alternatively, creating world object same, isn't nicest way it.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -