Game Development Reference
In-Depth Information
share source like ours will be; however, some games can benefit from receiving cer-
tain types of information. An example is a jigsaw game, which could let the player
share an image from another application to use as a puzzle during a later game. This
system facilitates the communication and provides a unique connection between
otherwise unrelated applications and games.
To become a share source we need to do two things:
• Register for the DataRequested event
• Provide the information when that event fires
All of this operates through the DataTransferManager class, which is a WinRT
type in charge of the share system. In our Game class we will register a handler
named ShareHandler using the previously covered TypedEventHandler class.
DataTransferManager::GetForCurrentView()->DataRequested
+=
ref new
Windows::Foundation::TypedEventHandler<
DataTransferManager^,
DataRequestedEventArgs^>(
this,
&Game::ShareHandler);
Once that is done we can implement the method, as shown in the following code
snippet:
void Game::ShareHandler(
DataTransferManager^ manager,
DataRequestedEventArgs^ args)
{
auto request = args->Request;
if (!_player->GetIsAlive())
{
request->Data->Properties->Title =
"My Score in Sample Game";
Search WWH ::




Custom Search