Discussion Forums  >  Uncategorized

Replies: 60    Views: 630

MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
12/30/11 09:17 PM (14 years ago)

Tutorial: Game Center

I put together a tutorial for integrating Game Center with the BT quiz. Note, this is only for iOS. I have not submitted a final app to iTunes yet, so there may be some issues I'm not aware of at this point. I've got it working well in two apps, and I'll submit them to Apple soon. If any adjustments need to be made, I'll correct and let you know. Please let me know if you have any problems or if you find typos, etc. Jeff http://www.jc-evans.com/uploads/Game_Center_Tutorial.pdf
 
DavidTheGreat
Aspiring developer
Profile
Posts: 13
Reg: Dec 27, 2011
Central Ohio
130
like
12/30/11 10:08 PM (14 years ago)
This tutorial and the song I was listening to while reading are what just gave me my second app idea! I'm not even kidding! Thanks :D Edit: Great tutorial too by the way. the screenshots make it so much easier to see what you're doing. Now how can I add custom achievements to the app?
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
12/30/11 10:40 PM (14 years ago)
A lot of the info I got was from these two tutorials. They helped a lot. You can implement the achievements, and they work. Just need to add some code and do a little more set up in iTunes Connect. http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-game-center-achievements-and-leaderboards-part-1/ http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-game-center-achievements-and-leaderboards-part-2/
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
12/31/11 12:45 AM (14 years ago)
@MGoBlue's awesome tutorial is also added to the How To's page. Good stuff.
 
Mackimack
Apple Fan
Profile
Posts: 481
Reg: Dec 30, 2010
Sweden
14,310
like
12/31/11 03:29 AM (14 years ago)
@MGoBlue Nice tutorial!
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
12/31/11 11:08 AM (14 years ago)
This is amazing!! Loved your urban airship tutorial and this Game Center Tutorial was exactly what I was looking for in a project I abandoned a couple months ago. Gonna try to implement this! Can't wait to see what you do next! ;)
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
12/31/11 12:11 PM (14 years ago)
@MGoBlue, I've gone through the whole tutorial. I get errors on one file the viewcontroller.h Take a look at the screenshot. All of the other code seems fine. What am I doing wrong here! http://dl.dropbox.com/u/5432778/Screen%20Shot%202011-12-31%20at%2012.56.30%20PM.png
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
12/31/11 12:37 PM (14 years ago)
@mitchellapps -- without having tested it yet. looks like you should have space in the viewcontroller.h after { ... GameCenterManagerDelegate> { perhaps?
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
12/31/11 12:39 PM (14 years ago)
Looks like you're missing a comma after AdBannerViewDel. That should fix it.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
12/31/11 12:50 PM (14 years ago)
Apparently a couple of my screenshot graphics were cut off. I've fixed that and corrected a couple of minor typos. New file is uploaded on my server. http://www.jc-evans.com/uploads/Game_Center_Tutorial.pdf
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
12/31/11 01:10 PM (14 years ago)
Ok, fixed that and I noticed that anything with quotes copied straight from your pdf caused errors so I fixed that. The app now builds, but Game Center says that this game is not recognized by Game Center. I missed a vital step somewhere. The kLeaderID is the ID we setup on itunes connect right? Is there somewhere else I should have place info?
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
12/31/11 01:17 PM (14 years ago)
Interesting about the quotes. My layout program obviously changed everything to smart quotes which don't work. I'll have to find a way to fix that. As for the kLeaderID, it is the 'Leaderboard ID' you set up at the beginning. Also, make sure your Bundle ID matches what you set up in iTunes Connect. Also, did you remember to enable Game Center for the current version of your app? (button changes to green once enabled).
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
12/31/11 01:33 PM (14 years ago)
Ok, yes, forgot to enable. Now we are cooking. 2 new issues for you. On my submit score button it says quizSubmitScore and when I tap that it shows Game Center with my app name and all but doesn't submit the score. When I tap show scoreboard the score I tried to submit is not there. How do I change the name of my button from quizSubmitScore and how to I ensure that my scores are being submitted?
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
12/31/11 01:37 PM (14 years ago)
Here are screenshots be better show what I'm talking about http://dl.dropbox.com/u/5432778/submit.png and http://dl.dropbox.com/u/5432778/leaderboard.png
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
12/31/11 01:48 PM (14 years ago)
For the button name, you missed this step: 6. Select the Localizable.strings file. It’s located in the BT_Config folder. Add the following under the //quiz section: quizSubmitScore = Submit Score; The score should be submitting. It doesn't show immediately. Don't know if that's a bug or how it's supposed to work. If you look at the scoreboard and click on one of the options (Today, This Week, All Time) and it should refresh and show the score.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
12/31/11 01:50 PM (14 years ago)
Make sure to include the quote marks around quizSubmitScore and Submit Score.
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
12/31/11 01:52 PM (14 years ago)
It looks like what is going on is when I tap quizsubmitscore it takes me to the leaderboard rather than submits my score.
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
12/31/11 01:57 PM (14 years ago)
I think there maybe some incorrect quotes that I may have missed fixing. Your probably right. I'll get back to you
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
12/31/11 01:58 PM (14 years ago)
You won't receive a message confirming that your score is submitted. That's why I added the routine to open the leaderboard after you submit the score. I just fixed the tutorial to get rid of the smart quotes.
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
12/31/11 02:09 PM (14 years ago)
Ok. Button correctly says Submit Score. I still don't think the score is submitting. When you tap Show Scoreboard it states that there are no scores.
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
12/31/11 02:11 PM (14 years ago)
If does take time to show up, I'll give a few hours. I've submitted multiple scores so hopefully they show up soon. I need a break anyway. Xcode makes my eyes hurt
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
12/31/11 02:26 PM (14 years ago)
I just remembered that I was having the same issue. When I googled it I found a forum post that said that Game Center won't show scores until there are more than one. I created another Game Center ID from my iPad and posted a score from that, then both scores showed up. I don't know if this is a Game Center bug, or something that's intentional. Check this thread out (see the last comment): http://www.iphonedevsdk.com/forum/iphone-sdk-development/92622-problem-score-reporting-game-center.html
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
12/31/11 02:51 PM (14 years ago)
Thanks! I'll check this out tomorrow and let you know! I appreciate everything!
 
ThomasB
Lost but trying
Profile
Posts: 162
Reg: Jun 23, 2011
Palo Alto
3,270
like
01/01/12 10:25 AM (14 years ago)
Thanks Jeff. Happy New Year!
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
01/01/12 10:37 AM (14 years ago)
@MGoBlue Alright, I created a separate Game Center Account on my iPad! Worked like a charm!!! Awesome tutorial!! I have a question though. I have multiple quiz categories that I'm doing in my app and was wondering if you knew a way to make a leaderboard for each category? That would be cool. Not sure if you've tried that. And oh yes, Happy New Year!
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
01/01/12 12:41 PM (14 years ago)
@mitchellapps - glad you got it working. I'm actually trying to tackle the multiple leaderboard question right now. I also have a quiz app with different quiz categories. I'll let you know if I get it worked out.
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
01/01/12 12:51 PM (14 years ago)
@MGoBlue Sounds Good! Thanks again!
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
01/01/12 11:36 PM (14 years ago)
@mitchellapps - OK. I've got multiple leaderboards working. Not sure if this is the most efficient way or if it will cause other issues, but in my testing it seems to work fine. First, set up several leaderboards in iTunes Connect. Then, in Buzztouch, modify the Screen Nickname of each quiz to match the corresponding LeaderboardID. In Xcode, make the following modifications: BT_screen_quiz.h Add the following at the end of the @property statements: @property (nonatomic, retain) NSString *itemNickname; BT_screen_quiz.m Under quiz properties */ change the last line to this: @synthesize quizButtonFontSizeSmallDevice, quizButtonFontSizeLargeDevice, finishedButtons, itemNickname; Replace the //submit score and //show scoreboard sections with the following: //submit score -(void)submitScore{ NSString *itemNickname = [BT_strings getJsonPropertyValue:screenData.jsonVars:@itemNickname:@]; self.currentLeaderBoard = itemNickname; if(totalPoints > 0) { [self.gameCenterManager reportScore: totalPoints forCategory: self.currentLeaderBoard]; } GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; if (leaderboardController != NULL) { leaderboardController.category = self.currentLeaderBoard; leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self; [self presentModalViewController: leaderboardController animated: YES]; } } //show scoreboard -(void)showScoreboard{ NSString *itemNickname = [BT_strings getJsonPropertyValue:screenData.jsonVars:@itemNickname:@]; self.currentLeaderBoard = itemNickname; GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; if (leaderboardController != NULL) { leaderboardController.category = self.currentLeaderBoard; leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self; [self presentModalViewController: leaderboardController animated: YES]; } } It's working for me. Let me know how it goes for you. Thanks.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
01/01/12 11:53 PM (14 years ago)
Strike that. Working on simulator but won't compile. More to do.....
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
01/02/12 11:27 AM (14 years ago)
Bummer! You had me excited! Lol! You'll figure it out! Your brilliant!
 
MacApple
Apple Fan
Profile
Posts: 4675
Reg: Oct 25, 2010
USA
61,150
like
01/02/12 01:54 PM (14 years ago)
@MGoBlue You around? Got push working this morning and trying to implement game center per your PDF. Getting multiple errors in BT_viewController.m Back to troubleshooting.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
01/02/12 04:02 PM (14 years ago)
@MacApple, what errors? I noticed when you copy/paste one section of code into BT_screen_quiz.m, it splits words leading to errors. If you want to email me direct, it may be easier. I don't get emails when people post to the thread for some reason. jeff at jc-evans.com @mitchellapps - It looks like I got it working great thanks to some advice from David Book. I'll update the pdf and post later today.
 
MacApple
Apple Fan
Profile
Posts: 4675
Reg: Oct 25, 2010
USA
61,150
like
01/02/12 04:14 PM (14 years ago)
You should have mail! Dollars coming your way, as soon as I dry them out!
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
01/02/12 04:24 PM (14 years ago)
Sounds great! Awesome job to you and David!
 
aussiedra
Code is Art
Profile
Posts: 431
Reg: Dec 25, 2010
Brisbane, Austr...
8,260
like
01/04/12 04:00 AM (14 years ago)
does this work on 1.5? should be able to auto submit scores with the end quiz fuction
 
aussiedra
Code is Art
Profile
Posts: 431
Reg: Dec 25, 2010
Brisbane, Austr...
8,260
like
01/04/12 06:03 PM (14 years ago)
users that which to have to auto submit scores at the end of the quiz without the user clicking submit do the following Remove //Submit Score Button [finishedButtons addObject:NSLocalizedString(@quizSubmitScore, @Submit Score)]; and add at //quizEnded //quizEnded -(void)quizEnded{ [BT_debugger showIt:self:@quizEnded]; [self.gameCenterManager reportScore: totalPoints forCategory: self.currentLeaderBoard];
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
01/09/12 07:49 PM (14 years ago)
Thanks MGoBlue again for the tutorial. I updated an app with this gamecenter code and it was approved today..Scores are coming in!!
 
Kahuna
Apple Fan
Profile
Posts: 137
Reg: Nov 18, 2011
Milan
4,670
like
01/12/12 10:47 AM (14 years ago)
Great tutorial MGoBlue, thank you! I tried to get the achievement working, got no error i the code but I made some mistakes and the achievement are not showing as achieved in game center. Did you have them working? I'll try the multiple leaderboard tonight.
 
Stefan
buzztouch Evangelist
Profile
Posts: 558
Reg: Dec 21, 2010
Sweden
14,780
like
02/10/12 06:24 AM (14 years ago)
@MGoBlue - First of all awesome tutorial! I have a weird issue - no matter how I try I get a following error: submitScore undeclared (first use in function) Any pointers? BR/Stefan
 
Stefan
buzztouch Evangelist
Profile
Posts: 558
Reg: Dec 21, 2010
Sweden
14,780
like
02/12/12 06:45 AM (13 years ago)
@MGoBlue - never mind. I did manage to fix that error. BR/Stefan
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/16/12 07:27 AM (13 years ago)
@Stefan - Glad you got it working. Unfortunately, I don't get email notifications when threads in the BT Forum are updated, so I have to remember to check back occasionally. Hence the slow replies sometimes. Happy its working for you. @Kahuna - I haven't tried achievements yet, but someone got it working and there's a tutorial in the BT help center. @aussiedra - Is that working for you? I'm going to give the code a try.
 
Wissam
I hate code!
Profile
Posts: 96
Reg: Dec 02, 2011
Dubai
1,660
like
03/01/12 12:53 PM (13 years ago)
@MGoBlue I have followed all the step and when i reached the following one i got the following code error in Xcode if (leaderboardController != NULL) { leaderboardController.category = self.currentLeaderBoard; ----------------------expected expression leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self; [self presentModalViewController: leaderboardController animated: YES]; am i missing something here or is it a pdf copy-paste errors? thanks for any help.
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
03/04/12 06:40 PM (13 years ago)
@MGoBlue: I also followed your tutorial but I did something wrong. It's a different issue than @Wissam's. Could you help me? My email is clevelandcib [at] aim.com
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
03/10/12 07:55 AM (13 years ago)
@wissam, I had the same issue. I think it's where you copy and paste. What I did was....click at the beginning of the second leaderboardController and then press delete all the way back to the ; Then press enter to send it to a new line Repeat that for each line and it seemed to correct the code Worked for me
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
03/10/12 07:57 AM (13 years ago)
@shak77 How about telling us what your issue is? We may be able to help ;)
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
03/11/12 06:10 AM (13 years ago)
@bonzo: I get the error "Semantic Issue: 'gameCenterManager' not found on object of type 'BT_screen_quiz*'; did you mean 'gameCenterManager'?" It's on the following line of code in the BT_screen_quiz.m: [self.gameCenterManager reportScore: totalPoints forCategory: self.currentLeaderBoard]; Any idea what I did wrong?
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
03/11/12 06:51 AM (13 years ago)
Sorry made a typo. After the error it says "did you mean 'gameCenterMangager'?" not "Manager"
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
03/11/12 07:03 AM (13 years ago)
Did you copy and paste from the PDF or type it yourself. I would do a search against your whole project. Do a 'find' from the 'edit' menu and search for mangager. If it finds it, change them all to manager.
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
03/11/12 07:14 AM (13 years ago)
Searched through and found that I had a typo that had "mangager" in it. I changed it to "manager" and now I have 2 errors. One of them is the same as before. The other says "Semantic Issue: use of undeclared identifier 'KLeaderboardID'; did you mean 'GKLeaderboard'?
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
03/11/12 08:03 AM (13 years ago)
I think the best thing to do is step though the guide again to Mae sur you typed it all correctly. Your safer bet is to copy and paste and then fix the issues with the " as yet don't copy well from the PDF.
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
03/11/12 01:15 PM (13 years ago)
I used the newer version that @MGoBlue has on his website so all the quotations are right and I did a full project search for anywhere that it says "mangager" and nothing came up.
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
03/11/12 01:51 PM (13 years ago)
for the semantic issue i think you are missing some { or } in the area that the error appears. double check your code matches the PDF
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
03/11/12 01:58 PM (13 years ago)
Checked it. Everything seems to match. Question about the kleaderboard thing- Do I replace the "kleaderboardID" part in the line of code that says: "self.currentLeaderBoard = kLeaderboardID;" with my game center id for the app?
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
03/11/12 02:01 PM (13 years ago)
no. that stays as it is. you only put your leaderboardID in the appspecificvalues.h file #define kLeaderboardID @"YOUR LEADERBOARDID"
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
03/11/12 02:03 PM (13 years ago)
Okay I did that. Should I just change the "gamecentermanager" to "gamecentermangager"? Will it mess everything up?
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
03/11/12 02:05 PM (13 years ago)
if you like, copy the complete text in bt_viewcontroller.h bt_viewcontroller.m lcalizable.string bt_screen_quiz.h bt_screen_quiz.m intonotepad or worddoc and then upload them somewhere where i can download, or email them to randalsp at sky dot com and i'lltake a look at them
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
03/11/12 02:06 PM (13 years ago)
also your appspecificvalues.h
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
03/11/12 02:07 PM (13 years ago)
That'd be great! Thanks. I'll put it together now.
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
03/11/12 02:16 PM (13 years ago)
Just sent it.
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
03/11/12 02:35 PM (13 years ago)
sent you 2 mails back with typo's i found
 
Mackimack
Apple Fan
Profile
Posts: 481
Reg: Dec 30, 2010
Sweden
14,310
like
09/09/12 11:39 PM (13 years ago)
@MGoBLue Thanks for the great tutorial. I wonder if you get the multiple scoreboard to work? Do you have any pdf for that to?
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.