You're right, some code...
This is the drawing routine.
void Ctext::edraw()
{
unsigned short textsprites=textsprite.size();
unsigned short effectsprites=effectsprite.size();
unsigned short i;
for(i=0; i < effectsprites; i++)
{
window->Draw(effectsprite[i]->sprite);
}
for(i=0; i < textsprites; i++)
{
window->Draw(textsprite[i]->sprite);
}
}
thats it, that simple.
you just called Ctext.edraw() every frame. the long code that creates the sprites is run once. its not in the main loop so can't be called again.
textsprite and effectsprite are both vectors of pointers to offsetsprite objects.
std::vector<offsetsprite*> textsprite;
std::vector<offsetsprite*> effectsprite;
struct offsetsprite
{
sf::Sprite sprite;
sf::Vector2f offset;
};
again, very simple. the offset vector variable contains the offset relative to the Ctext objects top left corner, so when you use my setposition() function, the position is set to the position fed into the function call, plus the offset.
textsprite[i]->sprite.SetPosition(pos.x + textsprite[i]->offset.x, pos.y + textsprite[i]->offset.y);
though not really that important to drawing the sprites.
Just in case it helps, and i doubt it, here is a few extracts from the textsprite creation function
void Ctext::createtextobjects()
{
if(font!=NULL)
{
deletetextobjects(); //just to make sure we're clean
sf::IntRect fontrect;
sf::Vector2f destpos(0,0);
offsetsprite *newtextsprite;
... lots of removed crap for calculating destpos
for(uint16 i=0; i < len; i++)
{
... more calculations
{
newtextsprite = new offsetsprite;
newtextsprite->offset.x = destpos.x;
newtextsprite->offset.y = destpos.y;
newtextsprite->sprite.SetImage(font->fontimage);
newtextsprite->sprite.SetColor(textcolour);
... removed fontrect calculations
newtextsprite->sprite.SetSubRect(fontrect);
newtextsprite->sprite.SetPosition(destpos.x + pos.x, destpos.y + pos.y);
textsprite.push_back(newtextsprite);
}
}
}
}