I had this code working in v1.4.3.1
But when I went to version 2 if two objects are too close to each other it somehow nulls out their position and they end up at 0,0.
If I move them a little further apart via the position.Set calls, it works fine.
//net bottom
PuzzleObjects[i].bodyDef = new b2BodyDef();
def = new b2PolygonDef();
def.SetAsBox(39/2, 24/2);
PuzzleObjects[i].bodyDef.userData = new BasketBottomIMG();
PuzzleObjects[i].bodyDef.userData.width = 39;
PuzzleObjects[i].bodyDef.userData.height = 24;
PuzzleObjects[i].bodyDef.position.Set(x,y+23);
PuzzleObjects[i].body=m_world.CreateDynamicBody(PuzzleObjects[i].bodyDef);
PuzzleObjects[i].body.CreateShape(def);
PuzzleObjects[i].bodyDef.userData.Parent=PuzzleObjects[i].bodyDef;
addChild(PuzzleObjects[i].bodyDef.userData);
//net right side
PuzzleObjects[i].bodyDef3 = new b2BodyDef();
var def2 = new b2PolygonDef();
def2.SetAsBox(24/2, 70/2);
PuzzleObjects[i].bodyDef3.userData = new BasketRightIMG();
PuzzleObjects[i].bodyDef3.userData.width = 24;
PuzzleObjects[i].bodyDef3.userData.height = 70;
PuzzleObjects[i].bodyDef3.position.Set(x+32,y);
PuzzleObjects[i].body3=m_world.CreateDynamicBody(PuzzleObjects[i].bodyDef3);
PuzzleObjects[i].body3.CreateShape(def2);
PuzzleObjects[i].bodyDef3.userData.Parent=PuzzleObjects[i].bodyDef3;
addChild(PuzzleObjects[i].bodyDef3.userData);
I did a trace into my update routine and the bb.GetPosition().x & y end up as NaN when the objects are too close. (When further apart they are fine)
for (var bb:b2Body = m_world.m_bodyList; bb!=null; bb = bb.m_next)
{
if (bb.m_userData is Sprite)
{
trace(bb.GetPosition().x);
bb.m_userData.x = bb.GetPosition().x;
bb.m_userData.y = bb.GetPosition().y;
}
What gives?????????????
But when I went to version 2 if two objects are too close to each other it somehow nulls out their position and they end up at 0,0.
If I move them a little further apart via the position.Set calls, it works fine.
//net bottom
PuzzleObjects[i].bodyDef = new b2BodyDef();
def = new b2PolygonDef();
def.SetAsBox(39/2, 24/2);
PuzzleObjects[i].bodyDef.userData = new BasketBottomIMG();
PuzzleObjects[i].bodyDef.userData.width = 39;
PuzzleObjects[i].bodyDef.userData.height = 24;
PuzzleObjects[i].bodyDef.position.Set(x,y+23);
PuzzleObjects[i].body=m_world.CreateDynamicBody(PuzzleObjects[i].bodyDef);
PuzzleObjects[i].body.CreateShape(def);
PuzzleObjects[i].bodyDef.userData.Parent=PuzzleObjects[i].bodyDef;
addChild(PuzzleObjects[i].bodyDef.userData);
//net right side
PuzzleObjects[i].bodyDef3 = new b2BodyDef();
var def2 = new b2PolygonDef();
def2.SetAsBox(24/2, 70/2);
PuzzleObjects[i].bodyDef3.userData = new BasketRightIMG();
PuzzleObjects[i].bodyDef3.userData.width = 24;
PuzzleObjects[i].bodyDef3.userData.height = 70;
PuzzleObjects[i].bodyDef3.position.Set(x+32,y);
PuzzleObjects[i].body3=m_world.CreateDynamicBody(PuzzleObjects[i].bodyDef3);
PuzzleObjects[i].body3.CreateShape(def2);
PuzzleObjects[i].bodyDef3.userData.Parent=PuzzleObjects[i].bodyDef3;
addChild(PuzzleObjects[i].bodyDef3.userData);
I did a trace into my update routine and the bb.GetPosition().x & y end up as NaN when the objects are too close. (When further apart they are fine)
for (var bb:b2Body = m_world.m_bodyList; bb!=null; bb = bb.m_next)
{
if (bb.m_userData is Sprite)
{
trace(bb.GetPosition().x);
bb.m_userData.x = bb.GetPosition().x;
bb.m_userData.y = bb.GetPosition().y;
}
What gives?????????????