Saturday 15 May 2010

objective c - Game Center login -


My game players need to log in with the apple game center. If they are a new player for the game, then they must first sign in to the game center because I use the player ID as part of the data used to set up a new user account.

I have a game center class that I use to sign in to the player, or signs them to sign if they are not already, then here is the main code .

  - (zero) setup {gameCenterAuthenticationComplete = NO; If (! IsGameCenterAPIAvailable ()) // // Game Center is not available NSLog (@ "Game Center is not available."); } And {nslog (@ "game center is available."); __Week type (self) weak Self = self; // Maintaining cycle error GKLocalPlayer * localPlayer = [GKLocalPlayer localPlayer]; // localPlayer public GKLocalPlayer __weak GKLocalPlayer * Vulnerable Player = Local Player; / Maintaining cycle error deletes weak player AuthenthenticateHandler = ^ (UIViewController * viewController, NSError * error) {if (viewController! = Null) {[weakSelf showAuthenticationDialogWhenReasonable: viewController]; } And if (weak player. Authentic) {[weak self certified player: weak player]; } And {{Weak gameman disabled]; }}; }} - (void) showAuthenticationDialogWhen appropriate: (UIViewController *) controller {[[UIApplication shared application] delegate] window] root view controller] PresentViewController: controller animated: Yes Full minus]; } - (void) certified player (Jikelokelpleyr *) Player {Anselog (@ "% @% @% @" player. Pleyraidi player. DisplayName, Kiladhiklias); LocalPlayer = player; GameCenterAuthenticationComplete = Yes; } - (zero) disableGameCenter {}   

And it works fine. But I have 2 problems

1) As I said that the player is new, they have to sign in to the Game Center before proceeding with the new user registration. This new registration is in the second category. So how do I hear GameCenter's variables gameCenterAuthenticationComplete = YES to other games? I read somewhere else that I can use a representative, but does he work in things? Will a notification be better in one object?

2) And more importantly, what if the player closes the modal to sign into the game center, where the call back / block where the modal is closed? So can I prompt them to sign in again or at least I can put a msg on the screen?

1) You gameCenterAuthenticationComplete by way of example that in your class header AppDelegate.m import and representatives of the interface can use your gameCenterAuthenticationComplete in (Appdelegate.h) in declaring an instance of that class came representative or you can reach sharedinstance class are the following measures adopted in your classroom Yourclass.h file

  + (YourClass *) shared person;   

and in YourClass.m

  Fixed YourClass * example; + (YourClass *) Shared Instruction {@ Synchronize (self) {if (example == zero) {Example = [[YourClass alloc] init]; }} Return example; }   

2) called on cancel button this method gamecenterleaderboardviewcontroller

  - leaderboardViewControllerDidFinish (zero): (GKLeaderboardViewController *) view_controller {[self.gameCenter DismissModalViewControllerAnimated: no]; [View-controller release]; }    

No comments:

Post a Comment