Game Development Reference
In-Depth Information
</visual>
</tile>
The template itself looks similar to the preceding block of XML. You can see there
are four lines of text available (in the template they're empty). If you wanted to pre-
define this XML and store it within your code, or in a separate file, you could do this,
load it in, and avoid the manipulation we're doing. As we want to update part of the
text based on the score, we're going to use the template and not worry about hand
crafting the XML.
var textElements =
xml.GetElementsByTagName("text");
textElements[0].InnerText = "Sample Game";
textElements[1].InnerText = "Score:";
textElements[2].InnerText = score.ToString();
Here you can see why we are using C# to manipulate the XML. We can easily set
the different lines as required. As shown, each of the lines are text tags so we can
easily retrieve those and set them in order. We begin with the name of the game,
and then a literal string that will display Score: before setting the score as the third
string. We can leave the fourth string as is, and it will not appear on the tile.
Once we have the XML ready, we just need to create a new TileNotification
and apply our XML data to it. With that, we can create a tile updater for the applica-
tion tile (as opposed to a secondary tile) and call Update , passing in the notification
we provided, as shown:
var notification = new TileNotification(xml);
TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
This is all we need on the C# side to update the tile. Now we just need to add the
following line to the end of the EndGame method within our Game class:
TileComponent::TileManager::UpdateScoreTile(_playerScore);
Search WWH ::




Custom Search