Game Development Reference
In-Depth Information
One of the things you want to do if you're in a trial mode is display some kind of
message screen to the users asking them to buy, or at least offer them an easy buy
button that lets them purchase your game without returning to the store. To do this
you should also show the current price of your game before they buy.
Traditionally you might hardcode this, and then have to issue a game update every
time you want to change the price, but using the store API you can retrieve details
about the store listing, and use that information to construct your up-sell page. This
is shown in the code snippet that follows:
concurrency::task<ListingInformation^>
listingTask(CurrentApp::LoadListingInformationAsync());
listingTask.wait();
try
{
auto listing = listingTask.get();
Platform::String^ price =
listing->FormattedPrice;
}
catch (Platform::Exception^ e)
{
// Operation failed, unable to connect maybe?
}
To retrieve the price of the game, we need to get the listing information, which con-
tains details such as the name, price, rating, and description, as shown in the store.
As we are retrieving this information from the store, we need to be able to connect
to the Internet, which means that this is an asynchronous operation, and it can fail.
These failures will be surfaced as exceptions that will appear to your game when you
call the get() method on the task. In the earlier example we aren't using the con-
tinuation system; instead, we are waiting for the task to complete.
The provided price is formatted for you in the local currency, so that you can use it
immediately in your user interface.
Search WWH ::




Custom Search