views:

26

answers:

0

Hi, i am using the following code to draw a circular edge in scene.

// Create edges around the entire screen
        b2BodyDef groundBodyDef;
        //groundBodyDef.position.Set(0,0);
        b2Body *groundBody = _world->CreateBody(&groundBodyDef);
        b2PolygonShape groundBox;
        b2FixtureDef boxShapeDef;
        boxShapeDef.shape = &groundBox;

            float angle; 
        float previousX;
        float previousY;
        float radius=50;

        for(int i = 0; i < 100; i++) { 
            angle = i*2*M_PI/100; 


            groundBox.SetAsEdge(b2Vec2(previousX,previousY), b2Vec2(240 + (cos(angle) * radius)/PTM_RATIO, 120 + (sin(angle) * radius)/PTM_RATIO));
            groundBody->CreateFixture(&boxShapeDef);
            previousX=240 + (cos(angle) * radius)/PTM_RATIO;
            previousY=120 + (sin(angle) * radius)/PTM_RATIO;

        } 

but i think the circular edge doesn't create properly...i can't test although... can anyone help me....??