Whenever I do this in box2d:
Nothing appears in debug when I do that.
However if I do this:
it works fine and I see a square in debug draw.
Why doesn't the first method work? I need it to work in case I want to make a pentagon or a trapezoid or a triangle.
Code:
// Either circle or polygon.
var shapeOfBox:b2PolygonShape = new b2PolygonShape;
// Amount of vertices.
var amountOfVertices:int = 4;
// Create a new array so we can put our coordinates of each
// point of a vertices.
var verticesOfBox:Array = new Array();
// The vertices go clockwise so I am going to
// start with the one in the top left.
verticesOfBox[0].Set(0, 0);
// Top right vertice of box.
verticesOfBox[1].Set(100, 0);
// Bottom right vertice.
verticesOfBox[2].Set(100, 100);
// Bottom left vertice.
verticesOfBox[3].Set(0, 100);
// Assign the vertices of our box to our
// shape as well as the amount of points there
// are.
shapeOfBox.SetAsArray(verticesOfBox, amountOfVertices);
var shapeOfBox:b2PolygonShape = new b2PolygonShape;
// Amount of vertices.
var amountOfVertices:int = 4;
// Create a new array so we can put our coordinates of each
// point of a vertices.
var verticesOfBox:Array = new Array();
// The vertices go clockwise so I am going to
// start with the one in the top left.
verticesOfBox[0].Set(0, 0);
// Top right vertice of box.
verticesOfBox[1].Set(100, 0);
// Bottom right vertice.
verticesOfBox[2].Set(100, 100);
// Bottom left vertice.
verticesOfBox[3].Set(0, 100);
// Assign the vertices of our box to our
// shape as well as the amount of points there
// are.
shapeOfBox.SetAsArray(verticesOfBox, amountOfVertices);
Nothing appears in debug when I do that.
However if I do this:
Code:
shapeOfBox.SetAsBox(100, 100);
it works fine and I see a square in debug draw.
Why doesn't the first method work? I need it to work in case I want to make a pentagon or a trapezoid or a triangle.