Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Winplex

Pages: [1]
1
Graphics / Re: Place text in the centre of a circle
« on: December 02, 2015, 07:24:46 pm »
Allright! I think I've sorted it out. I just changed one of the lines above to this:

Vector2f numRectCenter(numRect.width / 2.0 + numRect.left, numRect.height / 2.0 + numRect.top);

Great thanks for the help provided!  :)

2
Graphics / Place text in the centre of a circle
« on: December 02, 2015, 05:50:00 pm »
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.

Pages: [1]
anything