Yo, im making a stacking game and currently im about to make tetris shaped objects that drop on mouse.click
I'm having huge difficulties making my forloop loop out even 2 boxes at once inside the same object.
Ok so i have this working piece of code that renders out one box at mouseX/Y, how do i set it up to
render out, for instance, 3 boxes attatched to eachother instead of just 1?
Awesome replies gets a free cookie.
No, serisouly, help would be awesome.
I'm having huge difficulties making my forloop loop out even 2 boxes at once inside the same object.
Ok so i have this working piece of code that renders out one box at mouseX/Y, how do i set it up to
render out, for instance, 3 boxes attatched to eachother instead of just 1?
Awesome replies gets a free cookie.
No, serisouly, help would be awesome.
Code:
public function addBox(e:MouseEvent):void{
bodyDef = new b2BodyDef();
bodyDef.position.x = mouseX/30;
bodyDef.position.y = mouseY/30;
// Box
boxDef = new b2PolygonDef();
boxDef.SetAsBox(size, size);
boxDef.density = 1.0;
boxDef.friction = 0.5;
boxDef.restitution = 0.2;
bodyDef.userData = new PhysBox();
bodyDef.userData.width = size * 2 * 30;
bodyDef.userData.alpha = 1;
bodyDef.userData.height = size * 2 * 30;
body = m_world.CreateBody(bodyDef);
body.CreateShape(boxDef);
body.SetMassFromShapes();
addChild(bodyDef.userData);
bodyGraphArray.push(bodyDef.userData);
}
bodyDef = new b2BodyDef();
bodyDef.position.x = mouseX/30;
bodyDef.position.y = mouseY/30;
// Box
boxDef = new b2PolygonDef();
boxDef.SetAsBox(size, size);
boxDef.density = 1.0;
boxDef.friction = 0.5;
boxDef.restitution = 0.2;
bodyDef.userData = new PhysBox();
bodyDef.userData.width = size * 2 * 30;
bodyDef.userData.alpha = 1;
bodyDef.userData.height = size * 2 * 30;
body = m_world.CreateBody(bodyDef);
body.CreateShape(boxDef);
body.SetMassFromShapes();
addChild(bodyDef.userData);
bodyGraphArray.push(bodyDef.userData);
}