Game Development Reference
In-Depth Information
Where idol is the function in which we are going to build the idol:
private function idol(pX:Number,pY:Number):void {
var bodyDef:b2BodyDef=new b2BodyDef();
bodyDef.position.Set(pX/worldScale,pY/worldScale);
var polygonShape:b2PolygonShape=new b2PolygonShape();
polygonShape.SetAsBox(5/worldScale,20/worldScale);
var fixtureDef:b2FixtureDef=new b2FixtureDef();
fixtureDef.shape=polygonShape;
fixtureDef.density=1;
fixtureDef.restitution=0.4;
fixtureDef.friction=0.5;
var theIdol:b2Body=world.CreateBody(bodyDef);
theIdol.CreateFixture(fixtureDef);
}
At the moment we have just added another box shape, like the ones used for the
bricks, so there's no need to explain the code.
Test the movie and you'll see the body of the idol.
The second part of the idol we are going to create is the cross at its base. The cross
itself is formed by two box shapes just like the ones you are used to, but this time
they are rotated by 45 degrees clockwise and counterclockwise.
The creation of oriented box shapes is the next thing you will learn.
 
Search WWH ::




Custom Search