Code: Select all
void CreateRect( float x1, float y1, float x2, float y2 )
{
int num = 4;
float px, py, dx, dy;
cpBody *bod;
cpShape *shp;
px = ( x1 + x2 ) / 2.0;
py = ( y1 + y2 ) / 2.0;
dx = ( x2 - x1 ) / 2.0f;
dy = ( y2 - y1 ) / 2.0f;
cpVect verts[] = {
cpv(-dx,-dy),
cpv(dx, -dy),
cpv( dx, dy),
cpv( -dx, dy),
};
bod = cpBodyNew(INFINITY, INFINITY);
cpVect offset = cpv( px, py );
shp = cpSegmentShapeNew(bod, cpv(x1, y1), cpv( x2, y1), 0 ); //This works
// shp = cpPolyShapeNew(bod, num, verts, offset ); //This doesn't
shp->e = 1.0; shp->u = 1.0;
cpSpaceAddStaticShape(space, shp);
}
Any ideas?
Denis.