for (i = 0; i < 50; i++) {
circleDef.radius = Math.random()/20+0.02;
bodyDef = new b2BodyDef();
bodyDef.position.Set(Math.random()*8+140,1);
bodyDef.allowSleep = true;
bodyDef.linearDamping = 0.1;
bodyDef.angularDamping = 0.1;
b = world.CreateBody(bodyDef);
b.CreateShape(circleDef);
b.SetMassFromShapes();
var circle:Circle=new Circle()
circle.x= b.GetPosition().x* 50
circle.y= b.GetPosition().y* 50
circle.rotation = b.GetAngle() * (180/Math.PI);
screen.addChild(circle)
b.m_userData = circle;
}
1 comment:
/// stack
var sd:b2PolygonDef = new b2PolygonDef();
var bd:b2BodyDef = new b2BodyDef();
var b:b2Body;
sd.density = .1
sd.friction =.1;
sd.restitution = 0;
var j:int;
for (j = 0; j <8; j++) {
sd.SetAsBox(22/50, 12/50);
bd.position.Set(3800 / 50, (340-j*24)/50);//300
b = m_world.CreateBody(bd);
b.CreateShape(sd);
b.SetMassFromShapes();
/*
var brick:Brick=new Brick()
brick.x= b.GetPosition().x* 50
brick.y= b.GetPosition().y* 50
brick.rotation = b.GetAngle() * (180/Math.PI);
screen.addChild(brick)
b.m_userData = brick;*/
}
Post a Comment