hello,
i was wondering why some of my instanced sf::Strings were not working,
because i ran into some unexpected behavior.
*) what i want to do:
i want to copy a sf::string
*) this is what i was doing (should work IMHO, but does NOT)
sf::Font font;
//font gets loaded ... OK
sf::String label1;
label1.SetFont(font);
//rest of setup (color, style, size) and transformation ... OK
sf::String label2 = label1; //assuming all attributes get copied - NOT WORKING!
//just setup unique attributes of label2 ...
sf::String label3(label1); //assuming the same - NOT WORKING!
//setup unique attributes of label3 here ...
*) this is how i should do it in order to get it working
sf::Font font;
//font gets loaded ... OK
sf::String label1;
label1.SetFont(font);
//rest of setup (color, style, size) and transformation ... OK
//A - WORKS OK
sf::String label2;
label2.SetFont(font);
label2.SetSize(size);
//B - WORKS OK
sf::String label3("", font, size);
ok, i could use A and B, but wouldn't it be more natural to just copy it?
it seems like a problem with the copy ctor or copy assignment operator.
and i don't see a problem why this should not be working.
the font reference should be a shallow copy, the content a deep copy
and all the POD-like attributes can be copied easily anyway.
btw, as a kind of little request - what about a TextFormat class?
you can assign font, style, size, etc and assign it to different sf::Strings (which only hold the string content and a reference to this format).
this would save us a lot of typing and nice OO design
cheers, didi