Creating an oriented box shape
To create an oriented box shape, we will use a b2PolygonShape
method similar to SetAsBox
, yet more advanced and called the SetAsOrientedBox
method.
The arguments are the width and height of the box, the center of the box, also defined as a b2Vec2
object, and the rotation in radians.
- Applying this concept, the
idol
function continues in the following way:var bW:Number=5/worldScale; var bH:Number=20/worldScale; var boxPos:b2Vec2=new b2Vec2(0,10/worldScale); var boxAngle:Number=- Math.PI/4;
The first two lines are quite understandable as we are defining the size of the box, which is same as the box we just created.
Looking at the third line, where I define the position, you could have some doubts. The center of the body ...
Get Box2D for Flash Games now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.