Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

ShiVa3D

Return to Code Snippets

Game Center integrated!

Paste down any little snippets or request a new one.

Re: Game Center integrated!

Postby vklymenko » 10 Mar 2011, 20:08

yes, sometimes GameCenter doesn't work at all because their servers or something, maybe you should wait a day and try tomorrow, I don't know other solutions for now from my side as far I don't see your code

--
Thanks,
Slava
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby Markuzzzz » 15 Mar 2011, 20:53

vklymenko wrote:I haven't thinking about retrieving current player's name as far scores submitting automaticly to user, which is currently logged in,
but basicly it shouldn't be too hard to get current player's name:

there is a sample of how to retrieve top N scores/names from leaderboard at the end of the tutorial:
Code: Select all
- (void) fillMarkersTable

so there is a way to convert player's id/aliases, so what we need is just to know which ID we need, I think this should be a hint:

Code: Select all
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {

so we can extract player's name from "localPlayer"
I haven't did this, but thats my first thoughts : )


Ok added your thought :) I pass two parameters of the login user. I changed the following method:

Code: Select all
- (void)authenticateLocalPlayer {
   
   if(!isGameCenterAvailable()){
      return;
   }
    [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {     
      if (error == nil){         
         [self registerForAuthenticationNotification];

         NSString* aliasPlayer = [[GKLocalPlayer localPlayer]alias];
         NSString* idPlayer = [[GKLocalPlayer localPlayer]playerID];
         
         const char*cString = [idPlayer UTF8String];
         const char*cString2 = [aliasPlayer UTF8String];
         
         const void *params = [OurConvert getOurConvert:cString2 andY:cString];
         S3DClient_SendEventToCurrentUser("GameCenterController","onGameCenterLogged",2,params);
      }else{
         S3DClient_SendEventToCurrentUser("GameCenterController","onGameCenterOut",NULL);
      }
   }];
}


Now you also need to add two parameters in the handler in Shiva onGameCenterLogged( sAlias, sId )and you get the user info every time a user logs in from GameCenter. Now you can save and check to see if the account is still the same.

Markus
http://www.nifty-inspirations.com, because simple things are hard to find!
Markuzzzz
Platinum Boarder
Platinum Boarder
 
Posts: 578
Location: Netherlands

Re: Game Center integrated!

Postby vklymenko » 15 Mar 2011, 21:49

Hi!
cool thanks : ) I'll update later the tutorial with your change if you don't mind? : )

also I just updated the tutorial with this change:

in function (scripts)

Code: Select all
function MainAI.onGetNewMarkerData (  sName, sScore  )


I've removed

Code: Select all
        else
            break


because as experience showing, GameCenter returning highscores as e.g. "5,000m", so the dot can break converting and return 5000 as 5,
currently this part of code doesn't look professional and perfect but its parsing returned value and from "5,000m" it will extract all digits and it will be "5000" for sure : )
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby Markuzzzz » 28 Mar 2011, 12:15

I tested the game center using a new application in iTunesConnect. I cannot get it to work for an existing application which didn't have game center to begin with.

Does anyone have this problem? It keeps on telling me the game is not recognized. When I add a new application all works fine, but when I want to add a new version and enable Game Center the same way, it doesn't work..

kind regards,

markuzzzz
http://www.nifty-inspirations.com, because simple things are hard to find!
Markuzzzz
Platinum Boarder
Platinum Boarder
 
Posts: 578
Location: Netherlands

Re: Game Center integrated!

Postby vklymenko » 28 Mar 2011, 12:41

I don't know is that 100% correct answer, but what Im thinking is next:

if you've tested code and it works on a new app - then use the same code for the existing app. Apple says that GameCenter takes effect into existing app only after update released, so what I think is that you must to go with risk and submit the update with GameCenter without the fully testings. If everything else is correct - I believe GameCenter will start to work in released update downloaded from appstore. Just thoughts.
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby Diffa » 12 Apr 2011, 14:27

vklymenko wrote:btw I have only one issue for now with the integration: it works well on iphone, but in ipad's simulator (4.2) I see next:
- when I close a leaderboard for example screen doesn't want to receive any inputs anymore. I saw that before and the solution was
Code: Select all
[viewController.view.superview removeFromSuperview];

instead
Code: Select all
[viewController.view removeFromSuperview];

but even that seems not helping,
have someone experienced such issues?


I have the same problem. Everything works fine on iPhone, but on iPad you lose input after pressing done. Also the game center view is on Portrait while my game is landscape. Has someone found a working solution?
Diffa
Gold Boarder
Gold Boarder
 
Posts: 216

Re: Game Center integrated!

Postby Diffa » 28 Apr 2011, 11:20

bump!
Diffa
Gold Boarder
Gold Boarder
 
Posts: 216

Re: Game Center integrated!

Postby vklymenko » 28 Apr 2011, 11:27

hi, the bump is "got solution" or "to push searching" ? : )
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby Diffa » 28 Apr 2011, 11:35

still waiting for solution, so any news?
Diffa
Gold Boarder
Gold Boarder
 
Posts: 216

Re: Game Center integrated!

Postby vklymenko » 28 Apr 2011, 11:43

unfortunally no, I've tried everything possible, and now best solution I have is to remove "GameCenter" button from ipad versions and leave only in iphone's : )
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby Diffa » 28 Apr 2011, 11:58

:(
I was going to do the same, but instead of removing the game center button I'm going to use it open the game center application.

Code: Select all
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:"]];
Diffa
Gold Boarder
Gold Boarder
 
Posts: 216

Re: Game Center integrated!

Postby vklymenko » 01 May 2011, 14:34

its working for "minimal" requirements : )
thanks for this solution, I hadn't thiking of it, but will use that in ipad version, its much better then without GameCenter-button at all ; )
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby vklymenko » 14 Jun 2011, 20:21

(just in case: I've used
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:"]];
and my game was successfuly submitted to appstore, so if someone will worry about using url call in a game - no worry, it works. In other cases as I know opening URL in apps requiring to set 18+ for the app, just read somewhere...)
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby vklymenko » 20 Sep 2011, 16:03

(offtop: as I promised here you can find my InApp Purchase integration (iOS):
http://www.stonetrip.com/developer/forum/viewtopic.php?f=40&t=24139&p=38008#p38008)
User avatar
vklymenko
Platinum Boarder
Platinum Boarder
 
Posts: 758
Location: Europe

Re: Game Center integrated!

Postby FR_dZastrX » 21 Sep 2011, 11:00

Hi :) Thanks a lot for these tutorials, Vklymenko.
I am encountering the same problems as you were having ( ipad's simulator (4.2) ) both with Diffa :
----------------------------------------------
1.Closing leaderboard/Achiev, the screen doesn't want to receive any inputs anymore.
2.Gamecenter view is on Portrait while my game is landscape.

----------------------------------------------

Actually, copying and pasting your codes word by word ( or nearly :lol: ), xCode (v4) logs me 2 errors while compiling :

Code: Select all
leaderboardController.leaderboardDelegate = self;

Class '*' does not implement the '*' protocol
Class 'S3DEngine_EAGLView' does not implement the 'GKLeaderboardViewControllerDelegate' protocol


Code: Select all
achievements.achievementDelegate = self;

Class '*' does not implement the '*' protocol
Class 'S3DEngine_EAGLView' does not implement the 'GKAchievementViewControllerDelegate' protocol


...Maybe these errors are related to the issue ?
Do they mean anything to you, please ? :oops:

Still searching... :|
Last edited by FR_dZastrX on 21 Sep 2011, 11:25, edited 1 time in total.
FR_dZastrX
Gold Boarder
Gold Boarder
 
Posts: 164

PreviousNext

Return to Code Snippets