New Game Center Request APIs

Posted by

Game Center Request APIsA couple of weeks ago, we announced (standalone) Game Center support in Corona, and then showed you the basics of how to integrate it into your apps.

Since then, we’ve added support for more Game Center features to the gameNetwork.request() API, so today I’ll give you an overview of what those are. Before you continue, don’t forget to grab the latest Daily Build to ensure your implementation is up-to-date. At the moment, standalone Game Center support is available to subscribers only.

NOTE: This blog will go over some of the APIs that haven’t previously been discussed (outside of the API documentation)—this is not a Game Center integration tutorial. For a walk-through on how to get Game Center working in your Corona app, please see the previously published Game Center integration tutorial.

The following gameNetwork “request” types have been made available as of Daily Build 2012.730.

loadPlayerPhoto

This request will load the specified user’s Game Center avatar and create a Corona display object for it.

Request example:

gameNetwork.request( "loadPlayerPhoto",
{
        playerID = "G:0123456789",
        size="Small" -- "Small" or "Normal"
        listener=requestCallback
})

Going by the example shown above, the display object for the player’s avatar can be accessed from the requestCallback function via event.data (via the “photo” property). There are other important properties associated with this request, so before you implement this into your own app, be sure to take a look at the updated gameNetwork.request() documentation (scroll down to the “loadPlayerPhoto” section).

loadAchievementImage

This is similar to the loadPlayerPhoto request, but instead loads the image for a specified achievement. This is the same image you uploaded to iTunes Connect for the achievement, so be sure that the image you submitted is compatible with Corona (24-bit PNG files are your safest bet).

Request example:

gameNetwork.request( "loadAchievementImage",
{
        achievementDescription=
        {
                identifier="com.appledts.twenty_taps"
        },
        listener=requestCallback
})

As with loadPlayerPhoto, this request also creates a Corona display object, but instead it is accessed via the “image” property in the event.data table. Once again, see the gameNetwork.request() API documentation to see the full event table data.

Placeholder Images

The last two provide you with a Corona display object for Apple’s placeholder complete/incomplete achievement images:

  • loadPlaceholderCompletedAchievementImage
  • loadIncompleteAchievementImage

Returns the Apple-provided achievement images (complete/incomplete) in the form of a Corona display object (if you did not upload a custom one). The API for this is the same as loadAchievementImage but you do not specify specific achievement data (just a listener). The display object can be accessed from the “image” property of the event.data table in the callback listener you specified.

Other Requests

There are other requests, such as loadFriends, that are not shown in the sample code and were not covered in the previously published Game Center tutorial. These remaining requests are used in the same manner as the requests in the sample code and the tutorial, but return different properties in the event.data table. Please see the API documentation to see the exact properties that belong to event.data for the specific request you intend to make.

Once again, Game Center support in Corona is a subscribers-only feature for the time being, available through our exclusive Daily Builds program that each and every Corona subscriber has access to. If you’re ready to take your apps to the next level using the latest Corona features, to download the most recent build today.

Ready to get started?

Create amazing games and apps for iOS & Android

Leave a comment

Your comment