I didn't find any answer to my problem so far. Each i launch my game, the JVM gave me this error:
The idea is to create new object on the screen by creating new body with Box2D. So i create the class "loopCreateWeapon":
public class LoopCreateEnnemy {
private boolean isActive;
private BoxObjectManager boxObjectManager;
private Random r;
private float compteur;
private int lastTime;
public LoopCreateEnnemy(BoxObjectManager boxObjectManager) {
this.boxObjectManager=boxObjectManager;
r = new Random();
isActive=true;
compteur=0;
lastTime=-1;
}
public void update(float dt){
compteur += dt;
int compteurInt = (int) compteur;
if(isActive){
int mod = compteurInt%5;
if(lastTime!=compteurInt && mod==0){
int height= r.nextInt(GlobalSettings.VIRTUAL_HEIGHT);
System.out.println(lastTime +" - "+ compteurInt);
Weapon weapon = new Weapon(boxObjectManager.getNewObjectIndex(), 1, new Vector2(50,height));
weapon.setDensity(1f);
weapon.setRestitution(0f);
boxObjectManager.addObject(weapon);
}
}
lastTime=compteurInt;
}
}
(For explanation, i try to create a Weapon each second) I call the update method in the update method of my Screen class that implement the LoopCreateEnnemy.
I hope you'll be able to help me. I'm stuck with this situation.
Thanks !