This namespace provides an abstraction API for the Google Play Games Multiplayer Service.
Example
var GooglePlayGames = Cocoon.Social.GooglePlayGames; GooglePlayGames.init({ defaultLeaderboard: "xxxxx" }); var SocialGooglePlayGames = gpg.getSocialInterface(); var MultiplayerGooglePlayGames = gpg.getMultiplayerInterface(); SocialGooglePlayGames.login(function(loggedIn, error) { if(loggedIn){ var request = new Cocoon.Multiplayer.MatchRequest(2,2); var handleMatch = function(match, error){ } ... MultiplayerGooglePlayGames.findMatch(request, handleMatch); ... } });
Methods
-
<static> addPlayersToMatch(matchRequest, matchRequest, callback)
-
Automatically adds players to an ongoing match owned by the user.
Parameters:
Name Type Description matchRequest
Cocoon.Multiplayer.MatchRequest The parameters for the match.
matchRequest
Cocoon.Multiplayer.Match The match where new players will be added.
callback
function 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 matchRequest
Cocoon.Multiplayer.MatchRequest The parameters for the match.
callback
function 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 matchRequest
Cocoon.Multiplayer.MatchRequest The parameters for the match.
callback
function 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.