Working game Center Code?

Monkey Targets Forums/iOS/Working game Center Code?

OvineByDesign(Posted 2012) [#1]
I've tried all of the available Game Center code found on the forum, but Im getting a problem with the leaderboard screen not disappearing when you press the DONE button ?

A per forum posts I changed the 'controlleranimated' to NO which stopped the game from crashing when the done was pressed but alas teh screen doesnt disppear now at all?

Does anyone have any working Game center code ?


StuC


York(Posted 2012) [#2]
I have also trouble with GameCenter. I want to integrate it in landscape mode, but IPad works and IPhone not. :(

I donīt understand why there are the problems with Gamecenter.

Other question: Must be a button in the app to view leaderboard/achievement to get the app approved, if I use gamecenter?


arawkins(Posted 2012) [#3]
Hey guys, I've been using Alex's code from the other Game Center thread and as far as I know it hasn't been crashing. I've tested locally on ipod touch and ipad, but not iphone, both on ios5. I also ran it through the simulator without any issues (ios4, ipad and iphone). My game has been up for almost a week on the app store and no reports of problems, though it could be that nobody has bothered to tell me it crashes.

I've uploaded the code I'm using here:

http://www.rawkins.com/gamecenter.zip

There are also a few additional functions I've added:

Function GetAchievementCompletion:Float(scAchName$) - Returns the precentage completion of the achievement scAchName (the id of your achievement)

Function AchievementsLoaded:Bool() - Returns true once the players achievements have been loaded.

Function GetCancelCount:Int() - Returns the number of times the player has declined to log in to game center

Hope that helps! Let me know if it still causes crashing. Also I should mention my game is locked to landscape only, so I haven't tested any of this in portrait.


benmc(Posted 2012) [#4]
@arawkins Which game do you have in the app store right now using this Game Center code? I have an iPhone and can probably test it out.


arawkins(Posted 2012) [#5]
@benmc it's called Dolphin Up:
http://itunes.apple.com/ca/app/dolphin-up/id512064780?mt=8

That'd be great if you could test it. It's not a free app, but if you give me an email address or something I can send you a download code for it.


benmc(Posted 2012) [#6]
@arawkins Everything worked just fine on iPhone 3GS!

And wow, I'm glad I bought this game! Apple should feature it, it's REALLY fun. Reminds me of Tiny Wings, only more "free form", and more fun in my opinion.

I'm telling friends about it for sure.

I'll have to give Game Center another go, I couldn't get it to work myself the first time around.


OvineByDesign(Posted 2012) [#7]
Thanks for the post. The code does close the window now but now it crashes on the gtkxinput function once the window disappears. I also had to turn off the animation setting.

for( int pid=0;pid<32;++pid ){
if( touches[pid] && touches[pid].view!=view ) touches[pid]=0;   '<<<<<<<<
}



OvineByDesign(Posted 2012) [#8]
Hmm works in the simulator with ipad, just not iphone

/StuC


arawkins(Posted 2012) [#9]
@benmc Thanks! Glad you are enjoying it, and that it is running ok on your phone :)

@Ovine That's unfortunate, I'm not sure how much help I can be in regards to the crash as my knowledge of obj-c is pretty sparse. I haven't been able to cause a crash in the simulator though so I'm wondering if there is some crucial difference in the way our games are set up or when we are calling the OpenLeaderboard method. Here's how I have it set up.

The game is already paused or on the title screen whenever the leaderboard button gets hit, then the leaderboard opens. When it's closed, the game is still paused (or on the title screen). It's all done in the OnUpdate method.

More details: targeting ios 4.1, using these sdks:



OvineByDesign(Posted 2012) [#10]
thanks for the info

I am running in landscape mode (which might make a difference reading other threads on the subject)

I too pause the game when the leader board is onscreen, then on update monitors if it's taken offscreen, the. it resumes the game.

I can't understand why it works on the pad and not the iPhone - unless it's screen height related perhaps? I shall persever and report back.


Silverwolf(Posted 2012) [#11]
Any luck on getting this working on landscape mode.

For me getting Gamecenter working in landscape mode is a must if I am to use Monkey for IOS dev.