ShiVa3D
Game Center integrated!
Paste down any little snippets or request a new one.Re: Game Center integrated!
by vklymenko » 21 Sep 2011, 11:18
Hi FR_dZastrX,
thanks,
could you please archive and send me your "classes" folder from the xcode project to bizdev@splashfoxgames.com ? (i think its not to different from what usual UAT generates besides game center integration so we don't need NDA? : )
then I'll merge text/code with my "classes" folder and it will be easier to find the issues.
thanks,
could you please archive and send me your "classes" folder from the xcode project to bizdev@splashfoxgames.com ? (i think its not to different from what usual UAT generates besides game center integration so we don't need NDA? : )
then I'll merge text/code with my "classes" folder and it will be easier to find the issues.
Re: Game Center integrated!
by FR_dZastrX » 21 Sep 2011, 11:43
Hi : Done.
Indeed, simple update, following your tutorial, of the classes provided by the Stonetrip' UAT 1.2.beta16 : ...Are you using xCode4 ? ( Perhaps 3.2 does not give the same logs ? )
- FR_dZastrX
- Gold Boarder

- Posts: 164
Re: Game Center integrated!
by vklymenko » 21 Sep 2011, 12:22
thanks for the files, I've placed them into my project, compiled and hadn't got errors, only few warnings. Did you meant errors or warnings? Also I see some other changes with my classes folder, im using latest UAT and xcode I believe. Anyway i'll prepare and upload "tempalte" xcode project with game center integrated so you or anyone can use (then you can add feature as I founded - you did for sending player's name to scripts on success login etc.. : )
Re: Game Center integrated!
by vklymenko » 21 Sep 2011, 13:16
here is my classes folder
(i think i can share it as far general shiva PLE or any license can generate this part of code?)
probably everything that should be done:
- rename "HighscoresLeaderboardHere" in "S3DEngine_EAGLView.m" with your leaderboard id
and if needs - achiv1..16 downer.
- search/replace "MainAI" with AI model that you're using
and for scripts part shortest version of the tutorial:
onInit of your game:
add handlers:
onInitGameCenter
onGameCenterLogged:
onGameCenterOut:
onShowLeaderboard
onSubmitScores(scores)
and somewhere in game
for submitting scores:
for showing leaderboard:
(i think i can share it as far general shiva PLE or any license can generate this part of code?)
probably everything that should be done:
- rename "HighscoresLeaderboardHere" in "S3DEngine_EAGLView.m" with your leaderboard id
and if needs - achiv1..16 downer.
- search/replace "MainAI" with AI model that you're using
and for scripts part shortest version of the tutorial:
onInit of your game:
- Code: Select all
application.setCurrentUserEnvironmentVariable("bGameCenter",false)
user.postEvent ( application.getCurrentUser ( ),0,"MainAI","onInitGameCenter" )
add handlers:
onInitGameCenter
- Code: Select all
--empty
onGameCenterLogged:
- Code: Select all
application.setCurrentUserEnvironmentVariable("bGameCenter",true)
onGameCenterOut:
- Code: Select all
application.setCurrentUserEnvironmentVariable("bGameCenter",false)
onShowLeaderboard
- Code: Select all
--empty
onSubmitScores(scores)
- Code: Select all
--empty
and somewhere in game
for submitting scores:
- Code: Select all
local nSc = application.getCurrentUserEnvironmentVariable ( "Scores")
user.postEvent ( application.getCurrentUser ( ), 0, "MainAI", "onSubmitScores", nSc)
for showing leaderboard:
- Code: Select all
user.postEvent ( application.getCurrentUser ( ), 0, "MainAI", "onShowLeaderboard")
- Attachments
-
Classes.zip- (21.31 KiB) Downloaded 17 times
Last edited by vklymenko on 21 Sep 2011, 13:18, edited 1 time in total.
Re: Game Center integrated!
by FR_dZastrX » 21 Sep 2011, 13:18
Hi, thanks again for so fast answering and for posting your code template 
I'll definitively have a look at it right now
Only to answer back to the previous post : Yep, I meant "warnings"
...As the 2warnings I mentionned are concerning both the achievement and leaderboard showing processes ( S3DEngine_EAGLView.m
showAchievements / showLeaderboard )...I am affraid of the fact these two lines being ignored could point to the issue we have in the further "hiding" phases :
( S3DEngine_EAGLView.m
achievementViewControllerDidFinish / leaderboardViewControllerDidFinish )
...That's why I am wondering : Do you have the same warnings, please ?
I searched a lot and tried a lot of random crappy code in these "DidFinish" parts, but without success... The doc/links I used since now might be more clear for someone else ?
...Could it contain any info to help with this issue ?
( cf: Shiva App' not responding any more within iPad after closing the leaderboard/achievement panel )
http://stackoverflow.com/questions/4255375/lost-control-in-leaderboard-gamecenter
http://forums.macrumors.com/showthread.php?t=522922
http://stackoverflow.com/questions/1144496/how-to-correctly-removefromsuperview
...And what about using one of these 2 functions :
bringSubViewToFront
sendViewToBack
As I wrote upper, I am only discovering iOs thus sorry if I am out of the bounds
I'll definitively have a look at it right now
Only to answer back to the previous post : Yep, I meant "warnings"
...As the 2warnings I mentionned are concerning both the achievement and leaderboard showing processes ( S3DEngine_EAGLView.m
( S3DEngine_EAGLView.m
...That's why I am wondering : Do you have the same warnings, please ?
I searched a lot and tried a lot of random crappy code in these "DidFinish" parts, but without success... The doc/links I used since now might be more clear for someone else ?
...Could it contain any info to help with this issue ?
( cf: Shiva App' not responding any more within iPad after closing the leaderboard/achievement panel )
...And what about using one of these 2 functions :
bringSubViewToFront
sendViewToBack
As I wrote upper, I am only discovering iOs thus sorry if I am out of the bounds
- FR_dZastrX
- Gold Boarder

- Posts: 164
Re: Game Center integrated!
by vklymenko » 21 Sep 2011, 13:23
huh, I can also only ask for help for an experienced iOS objc programmer about this question, everything that I can think currently is maybe to add "GKLeaderboardViewControllerDelegate" into
S3DEngine_EAGLView.h
to
@interface S3DEngine_EAGLView : UIView <UITextFieldDelegate>
so the same as UITextFieldDelegate it will be transfered to the .m file
its probably doesn't have sense, just thought : )
S3DEngine_EAGLView.h
to
@interface S3DEngine_EAGLView : UIView <UITextFieldDelegate>
so the same as UITextFieldDelegate it will be transfered to the .m file
its probably doesn't have sense, just thought : )
Re: Game Center integrated!
by FR_dZastrX » 21 Sep 2011, 13:39
I thought about it too
...However, maybe that should be done into :
S3DEngine_ViewController.h
Indeed, according to :
http://www.iphonedevsdk.com/forum/iphone-sdk-game-development/65733-show-gamecenter-leaderboards-achievements-opengl.html
This kind of adding should be like that :
...A few unsuccessfull tries and I am back !
...However, maybe that should be done into :
S3DEngine_ViewController.h
Indeed, according to :
http://www.iphonedevsdk.com/forum/iphone-sdk-game-development/65733-show-gamecenter-leaderboards-achievements-opengl.html
This kind of adding should be like that :
Within these <> you can import delegates
- Code: Select all
@interface WhatEverViewController : UIViewController <GKAchievementViewControllerDelegate,GKLeaderboardViewControllerDelegate> {
}
...A few unsuccessfull tries and I am back !
- FR_dZastrX
- Gold Boarder

- Posts: 164
Re: Game Center integrated!
by FR_dZastrX » 21 Sep 2011, 15:05
...Ooh
Yess
ssss
!!! ( Meaning: I managed to make it. )
There is a proverb about a chimp who would be able to write Shakespeare, as long as there would be enough chimps to try
Then, in the iPad simulator, I can now call and close the achievement & leaderboard panels and then go back with success to my Shiva's App.
As these are my very first steps in the fabulous (but also dangerous).h and .m world, I wouldn't have found alone neither ; here is the literary track let by another chimp smarter than me : http://www.cocos2d-iphone.org/forum/topic/15390 ( The interesting part was there posted by SmallGaming )
...Thus, let's make some changes to the code written since now :
In S3DEngine_EAGLView.h , remove the lines you added during the tutorial :
In S3DEngine_EAGLView.m , remove the lines you added during the tutorial :
...Still in S3DEngine_EAGLView.m replace the lines you just removed by these ones ( And don't worry : there are only 2 voids only instead of 4, here, but we'll take care about the 2 others in an instant... ):
Now, still in S3DEngine_EAGLView.m, at the very top of the file, search for @implementation S3DMoviePlayerViewController ; the same way this has been implemented, we are about to add our 2 missing voids !
After the @end of the @implementation S3DMoviePlayerViewController , add :
( *This part is perhaps not necessary
) but I also did :
In S3DEngine_ViewController.h , add at the top :
...And then change 1 by 2 :
That's it ! Now you can close the achievement panel and be back to your App.
Note: At this time, I have a total of 1 warning in xCode while compiling :
S3DClient_SendEventToCurrentUser("AIM_GameCenter", "onGameCenterLogged",2,params);
Semantic Issue
Implicit declaration of function 'S3DClient_SendEventToCurrentUser' is invalid in C99
However, everything seems to work in the App ( I have the feedback of the Player Alias as expected... ??? ) and I am not sure I haven't made a mistake somewhere else... Please, if you try my solution, make a backup of your files first and tell me back what's up for you ?
There is a proverb about a chimp who would be able to write Shakespeare, as long as there would be enough chimps to try
Then, in the iPad simulator, I can now call and close the achievement & leaderboard panels and then go back with success to my Shiva's App.
As these are my very first steps in the fabulous (but also dangerous).h and .m world, I wouldn't have found alone neither ; here is the literary track let by another chimp smarter than me : http://www.cocos2d-iphone.org/forum/topic/15390 ( The interesting part was there posted by SmallGaming )
...Thus, let's make some changes to the code written since now :
In S3DEngine_EAGLView.h , remove the lines you added during the tutorial :
- Code: Select all
- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController;
- (void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController;
In S3DEngine_EAGLView.m , remove the lines you added during the tutorial :
- Code: Select all
-(void)showLeaderboard
{
UIWindow* window = [UIApplication sharedApplication].keyWindow;
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != nil) {
leaderboardController.leaderboardDelegate = self;
UIViewController *glView2 = [[UIViewController alloc] init];
[window addSubview: glView2.view];
[glView2 presentModalViewController: leaderboardController animated: YES];
}
}
//-----------------------------------------------------------------------------
-(void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
[viewController dismissModalViewControllerAnimated:YES];
[viewController.view.superview removeFromSuperview];
[viewController release];
}
//-----------------------------------------------------------------------------
-(void)showAchievements
{
UIWindow* window = [UIApplication sharedApplication].keyWindow;
GKAchievementViewController *achievements = [[GKAchievementViewController alloc] init];
if (achievements != nil){
achievements.achievementDelegate = self;
UIViewController *glView2 = [[UIViewController alloc] init];
[window addSubview: glView2.view];
[glView2 presentModalViewController: achievements animated: YES];
}
}
//-----------------------------------------------------------------------------
-(void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController
{
[viewController dismissModalViewControllerAnimated:YES];
[viewController.view.superview removeFromSuperview];
[viewController release];
}
...Still in S3DEngine_EAGLView.m replace the lines you just removed by these ones ( And don't worry : there are only 2 voids only instead of 4, here, but we'll take care about the 2 others in an instant... ):
- Code: Select all
//-----------------------------------------------------------------------------
- (void) showAchievements
{
UIWindow* window = [UIApplication sharedApplication].keyWindow;
AchievementController* achievementController = [[AchievementController alloc] init];
achievementController.achievementController = [[[GKAchievementViewController alloc] init] autorelease];
if (achievementController.achievementController != nil)
{
achievementController.achievementController.achievementDelegate = achievementController;
UIViewController *glView2 = [[UIViewController alloc] init];
[window addSubview: achievementController.view];
[achievementController presentModalViewController: achievementController.achievementController animated: YES];
}
}
//-----------------------------------------------------------------------------
- (void)showLeaderboard
{
UIWindow* window = [UIApplication sharedApplication].keyWindow;
LeaderboardController* leaderboardController = [[LeaderboardController alloc] init];
leaderboardController.leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease];
if (leaderboardController.leaderboardController != nil)
{
leaderboardController.leaderboardController.leaderboardDelegate = leaderboardController;
UIViewController *glView2 = [[UIViewController alloc] init];
[window addSubview: leaderboardController.view];
[leaderboardController presentModalViewController: leaderboardController.leaderboardController animated: YES];
}
}
Now, still in S3DEngine_EAGLView.m, at the very top of the file, search for @implementation S3DMoviePlayerViewController ; the same way this has been implemented, we are about to add our 2 missing voids !
After the @end of the @implementation S3DMoviePlayerViewController , add :
- Code: Select all
//-----------------------------------------------------------------------------------------
@interface AchievementController :UIViewController <GKAchievementViewControllerDelegate>
{
GKAchievementViewController *achievementController;
}
@property (nonatomic, readwrite, assign) GKAchievementViewController *achievementController;
- (void) achievementViewControllerDidFinish:(GKAchievementViewController *)viewController;
@end
@implementation AchievementController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES ;
}
@synthesize achievementController;
- (void) achievementViewControllerDidFinish:(GKAchievementViewController *)viewController
{
[self dismissModalViewControllerAnimated:YES];
[self.view removeFromSuperview];
[self release];
}
@end
//-----------------------------------------------------------------------------------------
@interface LeaderboardController :UIViewController <GKLeaderboardViewControllerDelegate>
{
GKLeaderboardViewController *leaderboardController;
}
@property (nonatomic, readwrite, assign) GKLeaderboardViewController *leaderboardController;
- (void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController;
@end
@implementation LeaderboardController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES ;
}
@synthesize leaderboardController;
- (void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
[self dismissModalViewControllerAnimated:YES];
[self.view removeFromSuperview];
[self release];
}
@end
( *This part is perhaps not necessary
In S3DEngine_ViewController.h , add at the top :
- Code: Select all
#import <GameKit/GameKit.h>
...And then change 1 by 2 :
- Code: Select all
@interface S3DEngine_ViewController : UIViewController
- Code: Select all
@interface S3DEngine_ViewController : UIViewController <GKAchievementViewControllerDelegate,GKLeaderboardViewControllerDelegate>
That's it ! Now you can close the achievement panel and be back to your App.
Note: At this time, I have a total of 1 warning in xCode while compiling :
S3DClient_SendEventToCurrentUser("AIM_GameCenter", "onGameCenterLogged",2,params);
Semantic Issue
Implicit declaration of function 'S3DClient_SendEventToCurrentUser' is invalid in C99
However, everything seems to work in the App ( I have the feedback of the Player Alias as expected... ??? ) and I am not sure I haven't made a mistake somewhere else... Please, if you try my solution, make a backup of your files first and tell me back what's up for you ?
Last edited by FR_dZastrX on 26 Sep 2011, 09:34, edited 1 time in total.
- FR_dZastrX
- Gold Boarder

- Posts: 164
Re: Game Center integrated!
by vklymenko » 21 Sep 2011, 15:45
thanks FR_dZastrX, cool : ) I'll try the fix today/tomorrow and will update original post ; )
Re: Game Center integrated!
by FR_dZastrX » 26 Sep 2011, 09:39
...I edited my previous post to add these lines in both the 2 viewcontroller ( leaderboard & achievement ) "implementations" :
& Now, my gamecenter shows up in landscape as well in portrait mode ( for iPad ) !
I really would have like, now, to code something related to the invitation abilities of the gamecenter...
Anyone to have been trying something about it until now ?
- Code: Select all
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES ;
}
& Now, my gamecenter shows up in landscape as well in portrait mode ( for iPad ) !
I really would have like, now, to code something related to the invitation abilities of the gamecenter...
Anyone to have been trying something about it until now ?
- FR_dZastrX
- Gold Boarder

- Posts: 164
Re: Game Center integrated!
by FR_dZastrX » 27 Sep 2011, 10:29
Mmm...
Nothing related to the changes I proposed above, but I am facing now some specific problem with the Authentification system to the gamecenter :
In order to reinitialize all the vars at once, when my player is coming back to the main menu, I am using the API function from Shiva : application.restart()
...However, in "restarting" like this, I have not the automatic gamecenter message "Hello again MrNoodle" appearing at the top...
Using logs, I can see I am going into the event "onInitGameCenter" but never into the "onGameCenterLogged" one ( neither into the "onGameCenterOut" one )
That's weird because, into the iOs Classes, as I a go though the callback : GameCenterSetInitCallback the var bGameCenterWantInit should be set to true and then, S3DEngine_GameCenter_WantInit should be triggered, and so on, the "authenticateLocalPlayer" ...Whatever it's a start or a re-start...
( And in the same time, it works just right if I pause the game and change my gamecenter profile )
...But that's not only "weird" ; that's also really annoying for me as showing the leaderboards, etc... becomes then no more possible
As I am also waiting for the event "onGameCenterLogged" to get back the pseudo and all the scores vars, that's really a pain in the
Please, anyone came accross this problem or might have an idea on how to resolve this ?
In order to reinitialize all the vars at once, when my player is coming back to the main menu, I am using the API function from Shiva : application.restart()
...However, in "restarting" like this, I have not the automatic gamecenter message "Hello again MrNoodle" appearing at the top...
Using logs, I can see I am going into the event "onInitGameCenter" but never into the "onGameCenterLogged" one ( neither into the "onGameCenterOut" one )
That's weird because, into the iOs Classes, as I a go though the callback : GameCenterSetInitCallback the var bGameCenterWantInit should be set to true and then, S3DEngine_GameCenter_WantInit should be triggered, and so on, the "authenticateLocalPlayer" ...Whatever it's a start or a re-start...
...But that's not only "weird" ; that's also really annoying for me as showing the leaderboards, etc... becomes then no more possible
As I am also waiting for the event "onGameCenterLogged" to get back the pseudo and all the scores vars, that's really a pain in the
Please, anyone came accross this problem or might have an idea on how to resolve this ?
- FR_dZastrX
- Gold Boarder

- Posts: 164
Re: Game Center integrated!
by juaxix » 01 Oct 2011, 02:56
vklymenko thank you , now i have full integrated game center in axyz game 
Re: Game Center integrated!
by vklymenko » 01 Oct 2011, 10:01
@juaxix: np, check, there is also IAP integration tutorial, if you'll need one ; )
@FR_dZastrX: sry, hadn't chance to test your implementation yet, but I will some day for sure. As for the another issue... do you mean you want to re-start game-center with another player? there is for sure should be a function that releasing current game-center objects. For example maybe it needs to release GKLocalPlayer ? just thoughts
@FR_dZastrX: sry, hadn't chance to test your implementation yet, but I will some day for sure. As for the another issue... do you mean you want to re-start game-center with another player? there is for sure should be a function that releasing current game-center objects. For example maybe it needs to release GKLocalPlayer ? just thoughts
Re: Game Center integrated!
by FR_dZastrX » 03 Oct 2011, 08:06
Hi vklymenko
Well, my goal is not to un-authenticate the current player : I don't want neither him to login again, nor another player to be able to login from my game.
( In my case, the game can be paused / resume, and thus I think the player can use the real gamecenter for such a feature. )
So, the same local player shall remain connected to the gamecenter, but there is a problem when the Shiva's application is restarting due to the API function
Indeed, if I totally stop my game, and then launch it ( still connected to the gamecenter ) ...I will have the message "Hello again" because the gamecenter authenticate process is correctly done and Gamecenter see me as yet connected.
However, now, if i use the
Well, my goal is not to un-authenticate the current player : I don't want neither him to login again, nor another player to be able to login from my game.
( In my case, the game can be paused / resume, and thus I think the player can use the real gamecenter for such a feature. )
So, the same local player shall remain connected to the gamecenter, but there is a problem when the Shiva's application is restarting due to the API function
- Code: Select all
application.restart()
Indeed, if I totally stop my game, and then launch it ( still connected to the gamecenter ) ...I will have the message "Hello again" because the gamecenter authenticate process is correctly done and Gamecenter see me as yet connected.
However, now, if i use the
- Code: Select all
application.restart()
- FR_dZastrX
- Gold Boarder

- Posts: 164
Re: Game Center integrated!
by FR_dZastrX » 21 Nov 2011, 13:32
Hi Folks 
My project is now also including matchmaker and everything works fine ( except perhaps the orientation changes that Shiva & OpenGL seems not to handle totally correctly for now )
I am using the U.A.T. 1.2.X and I ony came here to add these few lines in order to warn any people trying the 1.3.X betas : There might be some bug with the Stonetrip's Server connection ( Panels such as Leaderboard, etc... Won't show themselves no more with 1.3 releases, once the user is connected both to Gamecenter and to Stonetrip Server - while the same code is running under 1.2.b16 )
My project is now also including matchmaker and everything works fine ( except perhaps the orientation changes that Shiva & OpenGL seems not to handle totally correctly for now )
I am using the U.A.T. 1.2.X and I ony came here to add these few lines in order to warn any people trying the 1.3.X betas : There might be some bug with the Stonetrip's Server connection ( Panels such as Leaderboard, etc... Won't show themselves no more with 1.3 releases, once the user is connected both to Gamecenter and to Stonetrip Server - while the same code is running under 1.2.b16 )
- FR_dZastrX
- Gold Boarder

- Posts: 164
