Tutorial 21 - Integrating Game Center (Part 3)

phew! Finally finished part 3 of Integrating Game Center into your Lua Apps. In the process I forked @juaxix’s code on GitHub (https://gist.github.com/3887282) to allow multiple leaderboards and achievements. I’m starting to get the hang of how you link Objective C methods into Lua but I still have the “L” plates on so happy for someone to point out a better way.

In particular, rather than pass a string with the Game Center leaderboard or achievement identifier I’m using an integer (because I’m not sure how to pass a string) and then using the integer to pick out the appropriate string. This doesn’t feel particularly elegant but it does have the benefit of placing all the code where you need to put your Game Center ID’s in one file (aGameCenter_Codea.m).

I’m planning on submitting the updated version of MineSweeper (with Game Center support) to the App store.

You will notice a new MineSweeper logo on the Menu screen courtesy of @derhannes (web site at: http://www.boba-soft.com). @Fred - the mines now start falling from above the screen, thanks for the suggestion. @West - I believe the high score name bug is now sorted, thanks for catching this.

As an aside, once the Game Center code is used you can now longer test in Codea but updating, running and testing the Lua code in Xcode isn’t a bad alternate workflow (once you hard wire the runtime to reload the Lua code each compile).

Link for the Tutorial is http://codeatuts.blogspot.com.au/2012/10/tutorial-21-integrating-game-center.html

.@Reefwing thanks for keeping up the tutorials - though I’m not at the stage of releasing any of my apps yet, when I am in the position to do so, these will be my first point of call.

Thanks for your additions, uhm… I wonder why did you make three functions for 3 kinds of score in stead of one and use parameters like you do with achievements, kinda more of our philosophy =P~
There still a problem with submitting data with open source…you can change the code and hack your score/achievements,…

Hi @juaxix - good point, I have no reason for making each leader board submission a separate function. I agree that using a parameter would be more consistent. I will update it when I get a chance.

Also a good point about publishing my unique identifiers on a public site. I hadn’t thought of hacking achievements and scores. I will definitely change that!

You are doing a lot of good work to this community, thanks for that :slight_smile: