Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Returning the localplayer details in GameKit — Gideros Forum

Returning the localplayer details in GameKit

bowerandybowerandy Guru
edited September 2012 in Plugins
Hi @atilim,

I take it that the iOS GameKit plugin is maintained by Gideros, is that right? If so, I have made a simple modification that you may wish to include in the next release. This is to return the local player details (such as id and alias) as part of the authentication event. This is useful information to have available.

The change is simply to replace the current authenticate() function with:
	void authenticate()
	{
		if (isAvailable() == NO)
			return;
 
		[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError* error)
		{
               // Let's answer details of the local player in a players array
               NSArray *players= [NSArray arrayWithObject: [GKLocalPlayer localPlayer]];
               dispatchEvent(AUTHENTICATE_COMPLETE, error, NULL, players, NULL, NULL);
		}];	
	}
Then one can get at the info up in Gideros like this:
	function Game:onAuthenticateComplete(event)
	   if event.errorCode ~= nil then
		  print("error while authentication: "..event.errorDescription)
	   else
		  self.isGameCenterAuthenticated=true
		  self.gameCenterAlias=event.players[1].alias
		  print(string.format("authentication of %s successful. now loading friends...", self.gameCenterAlias))
		  gamekit:loadFriends()
	   end
	end
Best regards

Comments

Sign In or Register to comment.