The thing is that I have a set of CircleShape objects and the one of Text objects. What I need is to simply place each of those "texts" (their "strings" are basically numbers) in the centre of each of the circles. Like this:
The code snippets I'm trying to succeed in it with:
Vector2f center(width/2.0f, height/2.0f);
float angle = 0.0f;
float step = M_PI*2.0f/n;
float vxShapeRadius = 20.0f
for (int i = 0; i < n; i++)
{
vxShapes[i].setFillColor(Color::Blue);
vxShapes[i].setOrigin(vxShapeRadius, vxShapeRadius);
vxShapes[i].setPosition(center.x + 200.0f*cos(angle), center.y - 200.0f*sin(angle));
angle += step;
}
for (int i = 0; i < n; i++)
{
char buff[255] = {0};
nums[i].setFont(font);
nums[i].setColor(Color::Red);
nums[i].setCharacterSize(32);
nums[i].setString(_itoa(i+1,buff,10));
FloatRect numRect = nums[i].getGlobalBounds();
Vector2f numRectCenter(numRect.width/2.0, numRect.height/2.0);
nums[i].setOrigin(numRectCenter);
nums[i].setPosition(vxShapes[i].getPosition().x, vxShapes[i].getPosition().y);
}
Though I'm not getting what is required. In which line(s) did I do it wrong?
vxShapes is an array of CircleShape objects, nums is an array of Text objects.