Game Development Reference
In-Depth Information
_scoreText->Position.y = 50;
_scoreText->Text = std::wstring(L"Score: 0");
Inside Game::LoadContent we'll create a new TextBlock that will be named
_scoreText and keep a reference to that so that we can update the Text property
inside the AddScore method. We will position the score on the right-hand side of the
screen so that the player sprite doesn't clash with it, and give it an initial text so that
it doesn't suddenly appear later in the game.
_scoreText->Text = L"Score: " +
std::to_wstring(_playerScore);
This line needs to be added to the AddScore method to update the score string. We
can use to_wstring from the <string> header to help construct the string, ready
for use.
Search WWH ::




Custom Search