I am using spriteFont to draw strings to the screen, however I cant seem to be able to draw it with a variable as you would be able to in XNA
spriteFont->DrawString(spriteBatch.get(), L"Score: " + score, Vector2(10,10)........
Is this possible to achieve using C++ for windows 8 store applications?
Dec 2, 2013 at 10:16 PM
SpriteFont just takes a wide-character string. You can use any valid C++ method for building such a string.
A reasonably efficient method is to use traditional C printf routines (actually the wide-character, Safer CRT) which are supported in Windows Store apps
swprintf_s( buff, L"Score: %d\n", score );
spriteFont->DrawString( spriteBatch.get(), buff, Vector2(10,10)........
You can also use C++ std::wstring operations to compose your value, and then pass the result with .c_str() to DrawString.
ss << score;
std::wstring str( L"Score: " );
str += ss.str();
spriteFont->DrawString( spriteBatch.get(), str.c_str(), Vector2(10,10)........