Game Development Reference
In-Depth Information
The consumables
Consumables aren't officially supported by the Windows Store for Windows 8. The
solution to this lack of functionality is rather simple. We will start by creating a number
of products in the dashboard with the same identifier, except each one must have an
increasing number appended to it; for example:
• IAP-1
• IAP-2
• IAP-3
Once those are in place, we need to use a combination of the given techniques to
go through each one until we find one that hasn't been bought, and buy that. Each
product should have a minimum expiry of 1 day, so that effectively they can buy N
copies of the same product in a single day.
First retrieve the listing information so we know what products are in the store:
concurrency::task<ListingInformation^>
getlisting(CurrentApp::LoadListingInformationAsync());
getlisting.wait();
try
{
auto listing = getlisting.get();
int count = 1;
auto transformedId = identifier + L"-" + count;
while
(listing->ProductListings->Lookup(transformedId))
Now construct your identifier (of type Platform::String^ ) to match what you
have placed in the dashboard, including the index, which in this case is represented
by an int that we have named count . After that we will use a loop, inside which we
will add our purchase code. Each iteration will perform a lookup of the product. If it
exists with the current identifier, then we can try and buy it; if not then we have run
out of products for that identifier, and if by now we haven't purchased the product,
then we need to fail out and maybe indicate that the player should return the next
day. This is shown in the following code snippet:
Search WWH ::




Custom Search