Connecting to other types of online services

We'll now take a quick look at some of the other types of online services that games on mobile devices typically connect to. While we won't be covering these in depth, it's still worth giving them a mention in order to form a better picture of what is possible.

Supporting social gaming networks

Social gaming networks such as Apple's Game Center or cross-platform solutions such as Scoreloop or OpenFeint have become commonplace in many mobile games. In the following sections we will look at some of the possibilities we have available in Marmalade projects for these types of services.

Using Apple's Game Center

One of the most well-known social gaming systems in the mobile games world has to be Apple's Game Center (http://www.apple.com/game-center/). Unsurprisingly, this system is solely devoted to iOS-based devices, so if you are developing a game for iOS this is probably going to be your first choice for support.

We cannot access Apple's API directly given that it is an Objective-C library, so Marmalade instead comes with a wrapper API for the service, called s3eIOSGameCenter.

The s3eIOSGameCenter API is far too big for us to delve into here, but it is quite a close wrapping of the standard Apple-supplied API and thus fairly simple to understand how to convert any sample code you may come across on the Internet to use the Marmalade wrappers. An example project to demonstrate its use is supplied in the Marmalade installation folder exampless3eIOSGameCenter and there is plenty of information in the Marmalade documentation too, at Marmalade API Reference | S3E API Documentation | S3E: iOS Only | S3E iOS Game Center.

Support is provided for all the major features of Game Center, including leaderboards and achievements, multiplayer matchmaking, and even voice chat!

Using Scoreloop

The Scoreloop system is an extremely popular cross-platform solution that, at the time of writing, supports iOS, Android, BlackBerry PlayBook, and Windows Phone 7. Given that Marmalade supports the first three of these platforms, combined with the fact that the nice people at Scoreloop also supply a version of their API that can be used directly in a Marmalade project, this system is a very good choice if you want to support social gaming in a cross-platform project.

The Marmalade version of Scoreloop provides support for leaderboards, achievements, and Scoreloop's challenge system for offline multiplayer gaming.

More information on Scoreloop can be found at www.scoreloop.com, where you can sign up for a free developer account and download the latest version of the SDK.

Supporting in-app purchases

The current popularity of so-called Freemium games has come about because there are now other ways of charging for games besides a single up-front purchase cost. The advent of in-app purchases (IAP) has allowed us to literally give away our games for free and yet still make a profit by selling additional game modes or level packs to users after they have already played and enjoyed our games.

In the following sections we will be looking at how Marmalade allows in-app purchases to be supported on iOS and Android.

Adding in-app purchasing for iOS devices

As with Game Center, the in-app purchase SDK supplied by Apple is written in Objective-C, so we can't use it directly in a Marmalade project.

Again Marmalade solves this problem by wrapping up the Apple libraries into an API called s3eIOSAppStoreBilling.

This API allows us to obtain a list of in-app products that are available for purchase and their costs. We can then make a request to purchase a particular product and will be notified of success or failure when Apple's servers have taken care of all the behind-the-scenes stuff that needs to be done in order to process the payment.

Just like the original Apple implementation, there is no support for allowing a user to automatically download extra data when a purchase has been made. Instead we have to implement this ourselves on receipt of the purchase confirmation, which would involve either shipping all the "unlockable" data with the original application download or downloading it from our own server.

For more information on this API, take a look in the Marmalade documentation by going to Marmalade API Reference | S3E API Documentation | S3E: iOS Only | S3E iOS App Store Billing, and the example code that can be found in the Marmalade installation at exampless3es3eIOSAppStoreBilling.

Adding in-app purchasing for Android devices

Marmalade also provides a wrapper API for implementing in-app purchases on Android called s3eAndroidMarketBilling. The naming of this API is still based on the original name of the Android store (Android Marketplace), but it works fine with the renamed Google Play system.

Sadly Marmalade hasn't been able to provide a single API that can target multiple platforms, simply because the iOS and Android systems work so differently. A good example of this is that the Google Play system does not allow us to query the list of available products for an application. This is a really strange omission on Google's part (especially given that you do have to set up a product list on the Google Play servers anyway) and it means we either have to hardcode our product identifiers into our application or provide our own server to mirror this information.

Information on this API can be found in the documentation by going to Marmalade API Reference | S3E API Documentation | S3E: Android Only | S3E Android Market Billing, and there is some sample code at exampless3es3eAndroidMarketBilling.

Using advertising

We've just looked at in-app purchases as being one way of generating an income from your games, but another way is to make use of one of the many advertising solutions available. Just like those clickable adverts that are a common part of most websites, we can give over a little part of our game's screen display to adverts that will then provide another potential income stream.

The following sections explore some of the options available to us.

Implementing iAd support for iOS devices

As you are probably aware, Apple has its own advertising solution purely for iOS, called iAd. Again this requires use of an Objective-C API, so the Marmalade SDK provides a C wrapper for it called s3eIOSIAD.

This is a very simple API that allows you to request an advertisement from the iAd servers. If an advert is available you have control over when to show it, so the advert only needs to be visible at certain points in your game if you so wish.

Documentation on this API can be found at Marmalade API Reference |S3E API Documentation | S3E: iOS Only | S3E iOS iAd, and example code exists in the Marmalade installation directory at exampless3es3eIOSIAd.

Using other advertising solutions

Since iAd can only be used on iOS platforms, we are forced to consider other possible solutions when targeting other platforms (although most of these other solutions can still be used on iOS as it happens!).

Marmalade does not provide support for any other advertising systems directly, but other developers have taken up the challenge here and have made their own solutions available for use on the Marmalade Code Community pages.

At the time of writing there are a couple of useful projects called s3eAdWhirl and s3eAdNinja that at least provide support for Android. These solutions are quite clever in that they actually target multiple sources of mobile advertising in order to ensure that an advert is shown in your application as often as possible to maximize your revenue.

The IwGameAds module is another open-source community project that shows how to integrate with multiple ad services and works across more platforms than you can shake a very large stick at. The full source code and documentation for it can be found at the following web address:

http://www.drmop.com/index.php/iwgameads-sdk/

In the unlikely event that these don't suit your needs and there is a particular mobile advertising system you would like to use, another possibility is to implement your own support for that system using the Extensions Development Kit that is described in more detail in the next chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.3.167