New here? What’s IwGame? IwGame is an open source free to use cross platform game engine for iPhone, iPad, Android, Bada, Playbook, Symbian, Windows Mobile, LG-TV, Windows and Mac, built on top of the Marmalade SDK. You can find out more and download the SDK from our IwGame Engine page.
I can tell you one thing, testing in-app purchasing from scratch is NOT an easy task, in fact its a pain in the a** to be quite honest. However, like anything that’s cool its worth doing. Its been a while coming but we finally put together a unified API for in-app purchasing on the Android and iOS platforms. To see the end product in action check out Puzzle Friends on Android (the new name for the free version of cOnnecticOns (I must have been off my head when I invented the name cOnnecticOns :)). The iOS version is currently with the great Apple reviewers in the sky.
Ok, here is the list of changes for 0.33:
- In-app purchasing added for Android and iOS (IwGameMarket)
- Scenes can now be augmented after they have been created (like partial classes)
- Scenes can now be layered visually
- New SetAllTimelines action added to XOML that will set the timeline of all scenes
- SetVariable action now allows you to specify the scene in which the variable lives
- Resources can now be tagged with a tag name
- New RemoveResource and RemoveResources actions that allow removal of resources from global resource manager
- New CallActions action added that enables execution of other actions lists
- Actor now has ScaleX and ScaleY bindings
- Relative actor depth is now 0 for linked actors
- UDID removed from IwGameAds for iOS
- Scenes now have a ClipStatic property that will force the clipping area of a scene to stay in place on screen instead of moving with the scenes camera
- BUG FIX: Scene NotifyResuming now called properly
- BUG FIX: CIwGameAnimInstance::setAnimation() no longer crashes if NULL is passed
- BUG FIX: IwGameAdsView sprites are now updated correctly
The most interesting addition this update is the well hidden IN-APP PURCHASING for iOS and Android. With the aid of copy and paste lets take a look at the changes in more detail:
IwGameMarket – Unified In App Purchasing API for iOS And Android
Its an incredibly tough job to get noticed in the app stores these days with approaching half a million apps available in the larger stores (insane competition), its an even tougher job persuading Joe public to part with their money for your app. Many developers are turning to developing freemium titles as a means to increase visibility (app users are much more likely to download a free app) and earn money by offering the app in a limited form then allowing users to purchase additional content and game features. As of IwGame v0.33, basic in-app purchasing is now available for iOS and Android using a wrapper around Marmalade’s EDK in-app purchase extensions called IIwGameMarket.
IIwGameMarket is a not a concrete class however so you cannot just create one and use it. Instead it provides a basic interface for creating the platform specific market class as well as access to common functionality. At the moment the following marker classes are available:
CIwGameMarketiOS – Uses iOS in-app purchasing
CIwGameMarketAndroid – Uses Android market billing
CIwGameMarketTest – This version is a test class that you can use to simulate purchases / errors etc in the simulator.
IwGameMarket is designed to allow you to initialise and set-up and use in-app purchasing in a platform agnostic fashion, allowing you to query / purchase content very easily.
IwGameMarket works using a product list system, where you create and add CIwGameMarketProduct products to the IwGameMarket. Each CIwGameMarketProduct represents a single consumable / none consumable product that can be purchased.
Setting up the IwGameMarket is very simple, you simply call IIwGameMarket::Create() which initialises the correct market for the platform that your game or app is running on then set-up a few handlers, depending upon which messages you want to handle. Below shows a quick example:
IiwGameMarket::Create("Your android public key"); IIwGameMarket::getMarket()->setReceiptAvailableHandler(PurchaseComplete, NULL); IIwGameMarket::getMarket()->setErrorHandler(PurchaseError, NULL); IIwGameMarket::getMarket()->setRefundHandler(Refunded, NULL); // Android only
Note that if you are releasing for iOS only then you do not need to supply your Android Market public key, simply pass no parameters to Create().
In this example, we have told IwGameMarket that we want to be notified when a purchase receipt is available, when an error occurs or when a transaction refund has happened.
When done with the market don’t forget to clean it up using:
IIwGameMarket::Destroy();
Now that the market is set-up we need to add products, below shows a quick example:
// Which OS are we running int os = s3eDeviceGetInt(S3E_DEVICE_OS); // Create product 1 CIwGameMarketProduct* product = new CIwGameMarketProduct(); product->Consumable = true; product->ID = 1; product->Name = "10 Coins"; if (os == S3E_OS_ID_IPHONE) product->ExternalID = "com.companyname.gamename.coinsx10"; else product->ExternalID = "coinsx10"; product->Purchased = false; IIwGameMarket::getMarket()->addProduct(product); // Create product 2 product = new CIwGameMarketProduct(); product->Consumable = true; product->ID = 2; product->Name = "50 Coins"; if (os == S3E_OS_ID_IPHONE) product->ExternalID = "com.companyname.gamename.coinsx50"; else product->ExternalID = "coinsx50"; product->Purchased = false; IIwGameMarket::getMarket()->addProduct(product);
In this example, we create 2 products, our first represents 10 in-game coins, whilst the second represents 50 in-game coins. The ExternalID property is the product ID as defined in the in-app purchase section of your app in iTunes Connect for iOS or the product id of the in-app purchase in the in-app purchase section of your Android Market product control panel for Android. ID can be anything you like but will need to be unique.
Now that the system and product set-up are out the way, lets take a look at how to purchase a product. Firstly you need to call PurchaseProduct() passing in the ID defined in the CIwGameMarketProduct that you added earlier:
if (IiwGameMarket::getMarket()->PurchaseProduct(product_id)) { }
You then need to add code to the callbacks that we added in our set-up:
int32 MarketScene::PurchaseComplete(void* caller, void* data) { int type = IIwGameMarket::getMarket()->getLastPurchaseID(); if (type == 1) // 10 coins { GAME->AddCoins(10); } else if (type == 2) // 50 coins { GAME->AddCoins(50); } return 1; } int32 MarketScene::PurchaseError(void* caller, void* data) { // Display an error to the user return 1; } int32 MarketScene::Refunded(void* caller, void* data) { // Only available on th Andriod platform CIwGameString id = IW_GAME_MARKET_ANDROID->getRefundedID(); // Player was refunded so take back the items(s) return 1; }
Augmenting Scenes
Another cool new feature in v0.33 is the ability to augment a previously created scene and add extra stuff to it after the fact. You can for example have a basic common scene that provides the basic background of the scene. This gets loaded by many other scenes and serves as its basic background. After its been loaded you can declare the scene a 2nd time and add additional elements which will then be integrated into the original scene.
Layered Scenes
Scenes can now be depth sorted (visually only). This is incredibly useful as previously scenes would always be drawn in the order in which they were added to the game class. There is no limit to the layer number of a scene.
Tagged Resources
Resources can now be given a tag name, allowing you to identify groups of resources. New actions have also been added that allow the removal of specific resources or groups of tagged resources from the global resource manager. We added this new features because we found that sometimes it is very useful to have resources in the global resource manager so they can be shared across scenes, but later needed a way to remove those resources when done with them.
Calling Actions Lists
Its now possible to call an actions list from an action. This is great if you want to define lots of different action sets then pick and choose which ones you want to use.
And that’s it for this update, please enjoy.
Great update… surely I’ll add it to my current free game Balloon Challenge (https://play.google.com/store/apps/details?id=com.ar.balloonchallenge) to remove ads and access new challenge zones.