Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

iOS and MacOS / AGK iOS Game Center LeaderBoard (Easiest)

Author
Message
xGEKKOx
AGK Master
13
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 23rd Dec 2011 18:43 Edited at: 24th Dec 2011 02:41
Hi all boys,
after some days spent to understand the Game Center from the Halley tutorial and the GKTapper i found a great solution that work ever for C++ coders that won't to use UIButtons and IBActions.

Many thanks to Halley for his post that opened my eyes to learn some Obj C.
Ok let's go!

- 1 Step : We need to be clean...
Do a new folder (Group) called GameCenter and add inside it the GameCenterManager.h and GameCenterManager.m you will find them in the ZIP file attached and add them in the folder by clicking right mouse.

- 2 Step : Let's modify our UntitledViewController...
UntitledViewController.h


UntitledViewController.m


3 Step : Let's call our routine from everywhere in C++...
To call the GameCenter command from every where we need to alloc (not init) a variable. This must be placed in OurGame.cpp...
I suggest to put it on the top.


Remember to add this if you are not sure is already done in OurGame.h

We will use #import to be sure to not double the H files.

4 Step : Let's call what we need!!
To show the leaderboard...

To submit the score...

PlayerPoints can be INT

Well that's all.
I hope this will help all coders that have some problem on showing the subview for LeaderBoard.

iPhone/iPad Games : Street Karate Fighter - 90s VideoPokers Simulator - Arkanold

Attachments

Login to view attachments
bjadams
AGK Backer
14
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 23rd Dec 2011 19:16
Thanks for your help
xGEKKOx
AGK Master
13
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 24th Dec 2011 01:20 Edited at: 24th Dec 2011 02:43
Ok i fixed for iPad too.
I updated the first post with a perfect integration of LeaderBoard without adding other view or subviews and with no files additions!!!
Enjoy my friends!!

Edit : Added autorelease on scoreboard and optional fullscreen if you use the DeviceType (iPad/iPhone) to choose the Virtual Resolution.
If you don't use the device recognizing don't use the full screen for modal or it show with bug lines in the quarter of screen.

iPhone/iPad Games : Street Karate Fighter - 90s VideoPokers Simulator - Arkanold
bjadams
AGK Backer
14
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 24th Dec 2011 22:27
Gekko can you explain a little bit what you added to UntitledViewController.h and UntitledViewController.m ?
xGEKKOx
AGK Master
13
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 25th Dec 2011 16:42 Edited at: 25th Dec 2011 16:52
Of course my friend...

UntitledViewController.h
First of all we add this 2 lines to the top...


after added the GameCenter class header we can start to declare it...
so we add before the interface:


and we initialize it in the interface...


we need also to add the property for the class...


and than declare the functions (called "method" in obj c) for the .m file


Why i added the _score variable?
We don't need to do much turn around, we can go straight to our objective, so we can pass directly our C++ player points in a INT format (or in a format you want)

UntitledViewController.m
Here we need to add the new methods to the implementation, and is easy like in C++
But to get full features of the UntitledViewController we need to #import the Core.h


after we have to add a new synthesize of the GameManager class we added in .h


i also added this method from the GKTapper example cause AppGameKit don't have the message with title so the first method to add is this:

it will be very usefull...

After this i added the viewDidLoad that is not present in template...

This will autoinit the GameCenter class on the load of first view.

Finally i add the 2 methods to submit scores and load the leaderboard and the controller on close...


Now the last thing to add is a declaration in the cpp...

so we have a g_View variable where to pass the methods and variables.

I also added this to the .h file of cpp to be sure to have all features available in all files...


Now done this, we have finished.
To call the leaderboard we use: [g_View showLeaderboard];

To submit a score we use : [g_View submitScore:myvariable_points];

This workflow maybe will open your eyes on what we can do together with AppGameKit and Obj-C...
We can do very much things.
For example the showAlertWithTitle shows you how to use this method instead of agk::message.
Well AppGameKit staff surely will add it in next releases but in the while we wait we can mix C++/Obj C in an easy way.

The same process can be used also to integrate the inAppBuy and all the other features of the GameCenter. We finally don't need to add new views or subviews (until we really need them).

In the same way i'm trying to use buttons and menu from Obj-C and mixing to the AGK.
And i think will work very well. As the Input text is not usefull on AppGameKit, we can do it using the same way we are using for the game center.

Sorry for my rude english

iPhone/iPad Games : Street Karate Fighter - 90s VideoPokers Simulator - Arkanold
bjadams
AGK Backer
14
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 25th Dec 2011 20:47
GEKKO your English is fine.

Thanks a lot for the explanations.

I would be very interested in your experiments to use native ios buttons and menus with AGK. But maybe we should start a new topic for that
xGEKKOx
AGK Master
13
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 27th Dec 2011 13:46
Is all ok boys?
My tutorial work for everyone?

iPhone/iPad Games : Street Karate Fighter - 90s VideoPokers Simulator - Arkanold

Login to post a reply

Server time is: 2022-10-04 11:39:30
Your offset time is: 2022-10-04 11:39:30