This namespace provides an abstraction API for the Game Center Multiplayer Service.
Example
var GameCenter = Cocoon.Social.GameCenter;
var SocialGameCenter = gc.getSocialInterface();
var MultiplayerGameCenter = gc.getMultiplayerInterface();
SocialGameCenter.login(function(loggedIn, error) {
if(loggedIn){
var request = new Cocoon.Multiplayer.MatchRequest(2,2);
var handleMatch = function(match, error){
}
...
MultiplayerGameCenter.findMatch(request, handleMatch);
...
}
});
Methods
-
<static> addPlayersToMatch(matchRequest, matchRequest, callback)
-
Automatically adds players to an ongoing match owned by the user.
Parameters:
Name Type Description matchRequestCocoon.Multiplayer.MatchRequest The parameters for the match.
matchRequestCocoon.Multiplayer.Match The match where new players will be added.
callbackfunction The callback function. Response parameters: error.
-
<static> cancelAutoMatch()
-
Cancels the ongoing automatch request.
-
<static> findAutoMatch(matchRequest, callback)
-
Sends an automatch request to join the authenticated user to a match. It doesn't present a system view while waiting to other players.
Parameters:
Name Type Description matchRequestCocoon.Multiplayer.MatchRequest The parameters for the match.
callbackfunction The callback function. It receives the following parameters:
- Cocoon.Multiplayer.Match.
- Error.
-
<static> findMatch(matchRequest, callback)
-
Presents a system View for the matchmaking and creates a new Match.
Parameters:
Name Type Description matchRequestCocoon.Multiplayer.MatchRequest The parameters for the match.
callbackfunction The callback function. It receives the following parameters:
- Cocoon.Multiplayer.Match.
- Error.
-
<static> getMatch() → {Cocoon.Multiplayer.Match}
-
Get the current match reference.
Returns:
The current match reference.