{"id":1239,"date":"2012-04-06T17:40:27","date_gmt":"2012-04-06T17:40:27","guid":{"rendered":"http:\/\/www.drmop.com\/?p=1239"},"modified":"2012-04-07T14:04:46","modified_gmt":"2012-04-07T14:04:46","slug":"iwgame-engine-v0-33-released-unified-android-and-ios-in-app-purchasing","status":"publish","type":"post","link":"http:\/\/www.drmop.com\/index.php\/2012\/04\/06\/iwgame-engine-v0-33-released-unified-android-and-ios-in-app-purchasing\/","title":{"rendered":"IwGame Engine v0.33 Released \u2013 Unified Android and iOS in-app purchasing"},"content":{"rendered":"<p><a href=\"http:\/\/www.drmop.com\/wp-content\/uploads\/2012\/01\/IwGameLogo2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-705\" title=\"IwGameLogo2\" src=\"http:\/\/www.drmop.com\/wp-content\/uploads\/2012\/01\/IwGameLogo2-1024x300.png\" alt=\"\" width=\"512\" height=\"150\" srcset=\"http:\/\/www.drmop.com\/wp-content\/uploads\/2012\/01\/IwGameLogo2-1024x300.png 1024w, http:\/\/www.drmop.com\/wp-content\/uploads\/2012\/01\/IwGameLogo2-300x88.png 300w, http:\/\/www.drmop.com\/wp-content\/uploads\/2012\/01\/IwGameLogo2.png 1350w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\n<p>New here? What&#8217;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\u00a0on top of the\u00a0<a title=\"Marmalade SDK\" href=\"http:\/\/www.madewithmarmalade.com\/\" rel=\"nofollow\" target=\"_blank\">Marmalade SDK<\/a>. You can find out more and download the SDK from our\u00a0<a title=\"IwGame Engine\" href=\"http:\/\/www.drmop.com\/index.php\/iwgame-engine\/\" target=\"_self\">IwGame Engine page<\/a>.<\/p>\n<p>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&#8217;s cool its worth doing.\u00a0Its been a while coming but we finally put together a unified API for in-app purchasing on the\u00a0Android and iOS platforms. To see the end product in action check out <a title=\"Puzzle Friends  FREE for Android\" href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.pocketeers.puzzlefriends\" rel=\"nofollow\" target=\"_blank\">Puzzle Friends on Android<\/a>\u00a0(the new name for the free version of cOnnecticOns (I must have been off my head when I\u00a0invented the name cOnnecticOns :)). The iOS version is currently with the great Apple\u00a0reviewers in the sky.<\/p>\n<p>Ok, here is the list of changes for 0.33:<\/p>\n<ul>\n<li>In-app purchasing added for Android and iOS (IwGameMarket)<\/li>\n<li>Scenes can now be augmented after they have been created (like partial classes)<\/li>\n<li>Scenes can now be layered visually<\/li>\n<li>New SetAllTimelines action added to XOML that will set the timeline of all scenes<\/li>\n<li>SetVariable action now allows you to specify the scene in which the variable lives<\/li>\n<li>Resources can now be tagged with a tag name<\/li>\n<li>New RemoveResource and RemoveResources actions that allow removal of resources from global resource manager<\/li>\n<li>New CallActions action added that enables execution of other actions lists<\/li>\n<li>Actor now has ScaleX and ScaleY bindings<\/li>\n<li>Relative actor depth is now 0 for linked actors<\/li>\n<li>UDID removed from IwGameAds for iOS<\/li>\n<li>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<\/li>\n<li>BUG FIX: Scene NotifyResuming now called properly<\/li>\n<li>BUG FIX: CIwGameAnimInstance::setAnimation() no longer crashes if NULL is passed<\/li>\n<li>BUG FIX: IwGameAdsView sprites are now updated correctly<\/li>\n<\/ul>\n<p>The most interesting addition this update is the well hidden IN-APP PURCHASING for iOS and\u00a0Android. With the aid of copy and paste lets take a look at the changes in more detail:<\/p>\n<h2>IwGameMarket &#8211; Unified In App Purchasing API for iOS And Android<\/h2>\n<p>Its an incredibly tough job to get noticed in the app stores these days with approaching half\u00a0a million apps available in the larger stores (insane competition), its an even tougher job\u00a0persuading 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\u00a0purchasing is now available for iOS and Android using a wrapper around Marmalade&#8217;s EDK in-app\u00a0purchase extensions called IIwGameMarket.<\/p>\n<p>IIwGameMarket is a not a concrete class however so you cannot just create one and use it.\u00a0Instead it provides a basic interface for creating the platform specific market class as well\u00a0as access to common functionality. At the moment the following marker classes are available:<\/p>\n<p>CIwGameMarketiOS \u2013 Uses iOS in-app purchasing<br \/>\nCIwGameMarketAndroid \u2013 Uses Android market billing<br \/>\nCIwGameMarketTest \u2013 This version is a test class that you can use to simulate purchases \/\u00a0errors etc in the simulator.<\/p>\n<p>IwGameMarket is designed to allow you to initialise and set-up and use in-app purchasing in a\u00a0platform agnostic fashion, allowing you to query \/ purchase content very easily.<\/p>\n<p>IwGameMarket works using a product list system, where you create and add CIwGameMarketProduct\u00a0products to the IwGameMarket. Each CIwGameMarketProduct represents a single consumable \/ none consumable product that can be purchased.<\/p>\n<p>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:<\/p>\n<blockquote>\n<pre>IiwGameMarket::Create(\"Your android public key\");\r\nIIwGameMarket::getMarket()-&gt;setReceiptAvailableHandler(PurchaseComplete, NULL);\r\nIIwGameMarket::getMarket()-&gt;setErrorHandler(PurchaseError, NULL);\r\nIIwGameMarket::getMarket()-&gt;setRefundHandler(Refunded, NULL);\t\/\/ Android only<\/pre>\n<\/blockquote>\n<p>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().<\/p>\n<p>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.<\/p>\n<p>When done with the market don&#8217;t forget to clean it up using:<\/p>\n<blockquote>\n<pre>IIwGameMarket::Destroy();<\/pre>\n<\/blockquote>\n<p>Now that the market is set-up we need to add products, below shows a quick example:<\/p>\n<blockquote>\n<pre>\/\/ Which OS are we running\r\nint os = s3eDeviceGetInt(S3E_DEVICE_OS);\r\n\r\n\/\/ Create product 1\r\nCIwGameMarketProduct* product = new CIwGameMarketProduct();\r\nproduct-&gt;Consumable = true;\r\nproduct-&gt;ID = 1;\r\nproduct-&gt;Name = \"10 Coins\";\r\nif (os == S3E_OS_ID_IPHONE)\r\n\tproduct-&gt;ExternalID = \"com.companyname.gamename.coinsx10\";\r\nelse\r\n\tproduct-&gt;ExternalID = \"coinsx10\";\r\nproduct-&gt;Purchased = false;\r\nIIwGameMarket::getMarket()-&gt;addProduct(product);\r\n\r\n\/\/ Create product 2\r\nproduct = new CIwGameMarketProduct();\r\nproduct-&gt;Consumable = true;\r\nproduct-&gt;ID = 2;\r\nproduct-&gt;Name = \"50 Coins\";\r\nif (os == S3E_OS_ID_IPHONE)\r\n\tproduct-&gt;ExternalID = \"com.companyname.gamename.coinsx50\";\r\nelse\r\n\tproduct-&gt;ExternalID = \"coinsx50\";\r\nproduct-&gt;Purchased = false;\r\nIIwGameMarket::getMarket()-&gt;addProduct(product);<\/pre>\n<\/blockquote>\n<p>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.<\/p>\n<p>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:<\/p>\n<blockquote>\n<pre>if (IiwGameMarket::getMarket()-&gt;PurchaseProduct(product_id))\r\n{\r\n}<\/pre>\n<\/blockquote>\n<p>You then need to add code to the callbacks that we added in our set-up:<\/p>\n<blockquote>\n<pre>int32 MarketScene::PurchaseComplete(void* caller, void* data)\r\n{\r\n\tint type = IIwGameMarket::getMarket()-&gt;getLastPurchaseID();\r\n\tif (type == 1)\t\/\/ 10 coins\r\n\t{\r\n\t\tGAME-&gt;AddCoins(10);\r\n\t}\r\n\telse\r\n\tif (type == 2)\t\/\/ 50 coins\r\n\t{\r\n\t\tGAME-&gt;AddCoins(50);\r\n\t}\r\n\r\n\treturn 1;\r\n}\r\n\r\nint32 MarketScene::PurchaseError(void* caller, void* data)\r\n{\r\n\t\/\/ Display an error to the user\r\n\r\n\treturn 1;\r\n}\r\n\r\nint32 MarketScene::Refunded(void* caller, void* data)\r\n{\r\n\t\/\/ Only available on th Andriod platform\r\n\tCIwGameString id = IW_GAME_MARKET_ANDROID-&gt;getRefundedID();\r\n\r\n\t\/\/ Player was refunded so take back the items(s)\r\n\r\n\treturn 1;\r\n}<\/pre>\n<\/blockquote>\n<h2>Augmenting Scenes<\/h2>\n<p>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.<\/p>\n<h2>Layered Scenes<\/h2>\n<p>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.<\/p>\n<h2>Tagged Resources<\/h2>\n<p>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.<\/p>\n<h2>Calling Actions Lists<\/h2>\n<p>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. <\/p>\n<p>And that&#8217;s it for this update, please enjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>New here? What&#8217;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\u00a0on top of the\u00a0Marmalade SDK. You can find out more and download the SDK from our\u00a0IwGame Engine page. I can tell you one thing, testing in-app [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,155,112,118,286,66,44,154,42,181,111,28,148,3,357],"tags":[359,358,209,742],"class_list":["post-1239","post","type-post","status-publish","format-standard","hentry","category-android-app-development","category-apps","category-apps-and-games","category-c-programming","category-connecticons","category-cool-news","category-game-and-app-development","category-games","category-ios-app-development","category-iwgame-engine","category-marketing","category-marmalade-sdk","category-pocketeers-limited","category-programming","category-puzzle-friends","tag-android-in-app-purchasing","tag-ios-in-app-purchasing","tag-iwgame-engine-update","tag-puzzle-friends"],"_links":{"self":[{"href":"http:\/\/www.drmop.com\/index.php\/wp-json\/wp\/v2\/posts\/1239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.drmop.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.drmop.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.drmop.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.drmop.com\/index.php\/wp-json\/wp\/v2\/comments?post=1239"}],"version-history":[{"count":9,"href":"http:\/\/www.drmop.com\/index.php\/wp-json\/wp\/v2\/posts\/1239\/revisions"}],"predecessor-version":[{"id":1255,"href":"http:\/\/www.drmop.com\/index.php\/wp-json\/wp\/v2\/posts\/1239\/revisions\/1255"}],"wp:attachment":[{"href":"http:\/\/www.drmop.com\/index.php\/wp-json\/wp\/v2\/media?parent=1239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.drmop.com\/index.php\/wp-json\/wp\/v2\/categories?post=1239"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.drmop.com\/index.php\/wp-json\/wp\/v2\/tags?post=1239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}