Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 11    Views: 98

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

Game Center on iPad issue

Okay. Need a coding guru to help me figure this out. I've got a quiz app for a client with Game Center implemented. On an iPhone, all works well. After a user submits a score or views the scoreboard, the option list pops up asking them to continue, show scoreboard, submit score or quit. On the iPad, Game Center works fine except that after a user submits a score or views the scoreboard, the popup does not display again. The user is left at the beginning of the quiz with the start quiz button. You can see an example here: http://www.youtube.com/watch?v=GsOf20oboiY Any help or suggestions would be greatly appreciated.
 
XboxMods
buzztouch Evangelist
Profile
Posts: 718
Reg: Oct 28, 2011
location unknow...
12,080
like
08/18/12 09:50 AM (11 years ago)
I may have a Game Center code that is meant for the iPad. I will have to dig through my other projects to find it. You can email me at [email protected] I will send it when I find it soon.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
08/18/12 08:30 PM (11 years ago)
Thanks.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/18/12 10:16 PM (11 years ago)
Good video, makes tracking these kinds of things much easier! I don't have an app handy with Game Center enabled so we'll need to sleuth this out. What we do know: a) We know this works without game center and the options for Continue, Submit Score, Show Scoreboard, Quit show after on iPad without Game Center included. b) We know game center opens a UIViewController of it's own that you did not create. This is part of the Game Center logic. The method that shows the option (above) in the quiz screen plugin is called -(void)quizEnded. This method is near the bottom of the .m file. This method looks long but isn't to bad. Most of the code in this method is just determining how many buttons to show in the UIActionSheet that "pops up" to show the user. So, triggering the "quizEnded" method will show the options. When the quiz ends, the quizEnded method is triggered and the options show. This happens on iPhone and iPad, all good so far. This is confirmed in your video. Next, when the Show Scoreboard button is clicked you're showing the Game Center UIViewController. You must have some custom code in the -(void)showScoreboard method to show the Game Center UIViewController. Again, all good so far. The UIViewController is an instance of a iOS "leaderboard view controller." It's this leaderboard that's important. When this leaderboard id dismissed, on iPhone, the -(void)viewDidAppear:(BOOL)animated method on the underlying quiz screen is triggered which in tern triggers the -(void)quizEnded method if the quiz was completed. Again, calling the -(void)quizEnded method is what shows the options and we know this works on iPhone and iPad, right? This could only mean that on iPad the -(void)viewDidLoad method is not triggering after the user dismisses the leaderboard view controller. I'll be that iOS gives us a way to "listen" for this dismiss event and act on it. Dunno, just a hunch. If your quiz view controller has implemented any Game Center delegate methods, it may already have a "leaderboard cancelled" method? Not sure what it's called, look for something like "leaderboard cancelled" or "leaderboard closed" or "leaderboard completed" or something like that in the Game Center docs. I'll bet your quiz view controller has implemented a required protocol of Game Center? Summarize: You need to figure out when the leaderboard is closing and trigger the -(void)quizEnded event so you can show the options again.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
08/24/12 10:42 PM (11 years ago)
Thanks, David. This one's really got me pulling my hair out. I just can't find anything that would cause the iPad to react differently than the iPhone. It seems like the exact same code for each. Here's the portion of Game Center code from the BT_viewController.m file: - (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController { [self dismissModalViewControllerAnimated: YES]; [viewController release]; } //GameCenter View Did Unload - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; self.gameCenterManager = nil; self.currentLeaderBoard = nil; self.currentScoreLabel = nil; } - (void)dealloc { [gameCenterManager release]; [currentLeaderBoard release]; [currentScoreLabel release]; [super dealloc]; } I've played with subviews as well, but can't get anything to work. Surprised no one else has noticed this issue. I've tested it on a clean download and the same thing happens, so it's not a question of additional custom code I've added. BTW I just checked a 1.5 app that is live in the app store and it has the exact same issue. iPhone works perfectly, iPad does not. Any more thoughts?
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/24/12 10:58 PM (11 years ago)
Good info here. It looks like you've successfully implemented the leaderboardViewControllerDidFinish method. This should fire when the game center screen closes. Try calling the quizEnded() method inside that so it fires again when the leaderboard closes. Like.. - (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController { [self dismissModalViewControllerAnimated: YES]; [viewController release]; [self quizEnded] } The quizEnded method should show the options list again when it runs because the quiz is "over" and has not been restarted again. Bet it works.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
08/24/12 11:11 PM (11 years ago)
Yep. Tried that. Get an error. instance method '-quizEnded' not found (return type defaults to 'id') Tried defining and synthesizing quizEnded, but I think I'm too tired. Not getting it.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
08/24/12 11:20 PM (11 years ago)
Dang. Thought I had it. Moved the code block from BT_viewController.m to the BT_screen_quiz.m file and it worked perfectly for iPad, but now my iPhone implementation doesn't work. Essentially it calls the routine twice so you never are able to close it. I'll probably look at doing a conditional statement in the morning. Too tired right now. Thanks for everything. Hoping to get some time to finish up a couple of the plugins I've been working on. Right now, I've got a ton of updates I'm working on.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/24/12 11:22 PM (11 years ago)
Hmm...quizEnded triggered error, that's strange. For sure your class uses the quizEnded method. It should be defined in the .h and implemented in the .m. Find the actual method in the .m, put your tired eyes on it, make sure it exists. Laughing. I'm pretty sure it must because it gets fired earlier when the questions are done - right? So, triggering it in the leaderboardViewControllerDidFinish should not show a compiler error. I'm confused. There's an answer to this, we just gotta find it!
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/24/12 11:24 PM (11 years ago)
You're close. Ping this thread tomorrow, I'm beat too! Ha. night.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
08/25/12 07:40 AM (11 years ago)
Not the most elegant solution, I'm sure, but seems to be working fine. I added the following code to the BT_screen_quiz.m file: - (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController { //appDelegate alabamafootball_appDelegate *appDelegate = (alabamafootball_appDelegate *)[[UIApplication sharedApplication] delegate]; if([appDelegate.rootApp.rootDevice isIPad]){ [self dismissModalViewControllerAnimated: YES]; [viewController release]; [self quizEnded]; } else { [self dismissModalViewControllerAnimated: YES]; [viewController release]; } } I had to also leave the '- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController...' code in the BT_viewController.m file or I would get an incomplete implementation error. But it works!
 
MacApple
Apple Fan
Profile
Posts: 4674
Reg: Oct 25, 2010
USA
61,140
like
08/25/12 07:42 AM (11 years ago)
@MGoBlue Great stuff, you've made so many apps come to life with your Game Center integration, looking forward to (m)any plugins you might put together.
 

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.