Im experiencing a very strange behaviour. I have this world setup with one ragdoll and a number of thin wide boxes that make up the ground. I have a function that adds the next ground body so that it touches the previous box edge. This needs to be done because their rotation may vary. The problem occurs when i have run this function exactly 5 times (that is, added 5 ground boxes at world startup) - yesterday this number was higher, about 15, but there was still this limit. When i exceed it, my main loop wont run. Everything is added and every line of code is run, according to traces, except the main loop that never starts to run. Compiles fine.
Any ideas on what this might be?
EDIT: turns out its this one that only can be run 5 times
public function addGround(posX:Number, posY:Number, rot:Number = 0):b2Body
{
//shape
var boxDef:b2PolygonDef = new b2PolygonDef();
boxDef.SetAsBox(10 / 2, 0.4 / 2);
boxDef.density = 1.0;
boxDef.friction = 0.1
boxDef.restitution = 0.2;
//body
var bodyDef:b2BodyDef = new b2BodyDef();
bodyDef.position.x = posX
bodyDef.position.y = posY
bodyDef.angle = rot / (180/Math.PI)
bodyDef.userData = new ground_mc()
bodyDef.userData.name = "ground"
//create
var body:b2Body = m_world.CreateBody(bodyDef);
body.CreateShape(boxDef);
layers[0].addChild(bodyDef.userData);
return body
}
Any ideas on what this might be?
EDIT: turns out its this one that only can be run 5 times
Code:
public function addGround(posX:Number, posY:Number, rot:Number = 0):b2Body
{
//shape
var boxDef:b2PolygonDef = new b2PolygonDef();
boxDef.SetAsBox(10 / 2, 0.4 / 2);
boxDef.density = 1.0;
boxDef.friction = 0.1
boxDef.restitution = 0.2;
//body
var bodyDef:b2BodyDef = new b2BodyDef();
bodyDef.position.x = posX
bodyDef.position.y = posY
bodyDef.angle = rot / (180/Math.PI)
bodyDef.userData = new ground_mc()
bodyDef.userData.name = "ground"
//create
var body:b2Body = m_world.CreateBody(bodyDef);
body.CreateShape(boxDef);
layers[0].addChild(bodyDef.userData);
return body
}