Issue is extremely easy I guess, but I'm beginner, and I've tried many times.
Compound object, like from this tutorial :
http://www.emanueleferonato.com/2008/12 ... ith-box2d/
I try to skin walls of the maze :
And it doesn't work...I guess it may be problem with Update function - in my code it looks exactly like in this tutorial..
Any suggestions appreciated 🙂
Compound object, like from this tutorial :
http://www.emanueleferonato.com/2008/12 ... ith-box2d/
I try to skin walls of the maze :
Code:
bodyDef = new b2BodyDef();
bodyDef.userData=new wallBox();
bodyDef.position.Set(1,3);
body = m_world.CreateBody(bodyDef);
for (var j=0; j<9; j++) {
for (var i=0; i<9; i++) {
if (mazeArr[j][i]==1)
{
bodyDef.userData=new crate();
bodyDef.userData.width = 30;
bodyDef.userData.height = 30;
bodyDef.userData.name="wall";
addChild(bodyDef.userData);
boxDef = new b2PolygonDef();
boxDef.SetAsOrientedBox(0.5,0.5,new b2Vec2(i, j), 0);
boxDef.density=1;
boxDef.friction=0.5;
boxDef.restitution=0.2;
body.CreateShape(boxDef);
}
}
}
body.SetMassFromShapes();
bodyDef.userData=new wallBox();
bodyDef.position.Set(1,3);
body = m_world.CreateBody(bodyDef);
for (var j=0; j<9; j++) {
for (var i=0; i<9; i++) {
if (mazeArr[j][i]==1)
{
bodyDef.userData=new crate();
bodyDef.userData.width = 30;
bodyDef.userData.height = 30;
bodyDef.userData.name="wall";
addChild(bodyDef.userData);
boxDef = new b2PolygonDef();
boxDef.SetAsOrientedBox(0.5,0.5,new b2Vec2(i, j), 0);
boxDef.density=1;
boxDef.friction=0.5;
boxDef.restitution=0.2;
body.CreateShape(boxDef);
}
}
}
body.SetMassFromShapes();
And it doesn't work...I guess it may be problem with Update function - in my code it looks exactly like in this tutorial..
Any suggestions appreciated 🙂