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 / [Tutorial : iOS/MAC] Game Center : Get Names, Ranks, Avatars and show them

Author
Message
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 24th May 2013 15:09 Edited at: 24th May 2013 15:44
Ok let's see this time how to get the MULTIPLAYER connected avatars and show them.
This tutorial is for the coders already know how to start a multiplayer game with the Game Center.
So you have the NSArray of the connected players.... (this is for 2 players game)

Important A:
You need to use the way to call the untitled view controller i shown in my template (in another post) or you need to create your way.

Important B:
In this code there is a rotation used when the old AppGameKit version had bugs on the UIInterfaceOrientation, so maybe now we
don't need it. Do some test.

UntitledViewController.h


The "version" is the iOS version when the avatars functions was added.

UntitledViewController.m


After this code you have 2 (global) variables:
- Avatar1 = true;
- Avatar2 = true;
When they are both true you can change your state from "waiting avatars", for example, to the next.
This is the only reason i added this, the loading of avatar is not sync but async, so you need to wait.

Now let's see the rank.


I use this method to get 1 score but you can edit it as you need, you can also submit a query with a range.
Of course change the category with your own.
You can also change the scope of the query and request other things like friends or who play this game.

This is the Apple example:


Now let's see how to get names:
This is more complex to understand.
You need the ListPlayers array ready to be filled with the players connected.
In fact, this function is called by the GKMatchViewController delegate when a player will connect.
You can see, as i'm using it for 2 players only, it store the connected player name and change the status to the next (start fighting)...



Those methods are very small in lines of code and work perfectly with my template.
Using my template you can call it wherever you are as the .h is included in the entire project.

If i forget to say something or you need other, don't hesitate to ask.


Long life to Steve!
halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 24th May 2013 15:40
Thank you. I'm trying these code.

The Miracrea Games
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 24th May 2013 15:45
Ok i editetd with some other codes.

Long life to Steve!
halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 24th May 2013 15:57
I can't compile it , so I maybe need your help later.

The Miracrea Games
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 24th May 2013 16:19
Remember the declaration of the appDelegate from my template.
The AppGameKit view is not the "self" everywhere, so you need the shared one to get some delegate.

Long life to Steve!
halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 24th May 2013 17:28
May I ask your Skype?

The Miracrea Games
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 24th May 2013 17:29
xgekk0x is my nick
the o is a zero

Long life to Steve!

Login to post a reply

Server time is: 2024-03-28 18:51:54
Your offset time is: 2024-03-28 18:51:54