Sign In Register

How can we help you today?

Start a new topic
Answered

Need some Android examples

Hi GS,


I m new user, and looking service for realtime turn based game, i have checked all documentation and codes, but its difficult to understand me, can u please link me some examples of android, so i can study that codes.


Thanks.


Best Answer

Hi Swapnil,


First of all, apologies for the delay in answering your questions. At this time we only have in-depth tutorials for Unity3D which you can find on on our Tutorials page on our Learn section.


The tutorial there covers logging in users via Facebook, creating a leaderboard and posting and retrieving scores.


We have a new video tutorial specifically for doing challenges in Unity on Youtube which you can view by clicking here. The documentation for this video series is not yet ready as we want to ensure it's quality and ease of use. It should be ready in the next couple of days.


Even though the videos are for Unity, the process is almost the exact same for the Android SDK and can be easily followed, only requests are coded differently while setting up the portal and cloud code are the same regardless of engine.


In Unity a CreateChallengeRequest() looks like:

 

//we use CreateChallengeRequest with the shortcode of our challenge, we set this in our GameSparks Portal
		new CreateChallengeRequest().SetChallengeShortCode("ticTacToe")
			.SetUsersToChallenge(userIds) //We supply the userIds of who we wish to challenge
			.SetEndTime(System.DateTime.Today.AddDays(1)) //We set a date and time the challenge will end on
			.SetChallengeMessage("I've challenged you to Tic Tac Toe!") // We can send a message along with the invite
			.Send((response) =>
			{
				if (response.HasErrors)
				{
					Debug.Log(response.Errors);
				}
				else
				{
					//Show message saying sent!;
				}
			});

 

In Java that would be:

    

Map<string, object> data = new HashMap<string, object>();
data.put("@class" : ".CreateChallengeRequest"); //The type of request we're sending
data.put("challengeShortCode" : "ticTacToe"); //The shortcode of the challenge we created on the portal
data.put("endTime" : "2013-12-31T12:00Z"); //When the challenge ends
data.put("usersToChallenge" : "524c13c7e4b0f3abf2b1ddc0"); //The users we want to challenge
Map<string, object> result = gamesparksApi.send(data); //Send our request

   

Similarly, to list all running challenges and get information from them your ListChallengeRequest() in Unity looks like:

  

new ListChallengeRequest().SetShortCode("ticTacToe") //List all challenges with the shortcode "ticTacToe"
			.SetState("RECEIVED") //We only want to get games that we've received
			.SetEntryCount(50) //We want to pull in the first 50 we find
			.Send((response) => //The data we want is stored in the response
			{
				foreach (var challenge in response.ChallengeInstances)
				{
					string challengeId = challenge.ChallengeId;
				}
			}

  

In Java it would look like:

  

Map<string, object> data = new HashMap<string, object>();
data.put("@class" : ".ListChallengeRequest"); //List all challenges
data.put("shortCode" : "ticTacToe"); //with the shortcode "ticTacToe"
data.put("state" : "Running"); //Retrieve currently running games
data.put("entryCount" : 100); //Grab the first 100 we find
Map<string, object> result = gamesparksApi.send(data); //Send our request, the data we want is stored in the result.

  

Hope that helps,

Shane


It seems that GameSparks is not interested to reply this thread, also have very poor tutorials, so its impossible to understand to newbies.

Swapnil


Our customer services team is working on completing a tutorial that will work for you right now.  The tutorial will be complete with documents, videos and sample code.  Please just bear with us.


John.

Answer

Hi Swapnil,


First of all, apologies for the delay in answering your questions. At this time we only have in-depth tutorials for Unity3D which you can find on on our Tutorials page on our Learn section.


The tutorial there covers logging in users via Facebook, creating a leaderboard and posting and retrieving scores.


We have a new video tutorial specifically for doing challenges in Unity on Youtube which you can view by clicking here. The documentation for this video series is not yet ready as we want to ensure it's quality and ease of use. It should be ready in the next couple of days.


Even though the videos are for Unity, the process is almost the exact same for the Android SDK and can be easily followed, only requests are coded differently while setting up the portal and cloud code are the same regardless of engine.


In Unity a CreateChallengeRequest() looks like:

 

//we use CreateChallengeRequest with the shortcode of our challenge, we set this in our GameSparks Portal
		new CreateChallengeRequest().SetChallengeShortCode("ticTacToe")
			.SetUsersToChallenge(userIds) //We supply the userIds of who we wish to challenge
			.SetEndTime(System.DateTime.Today.AddDays(1)) //We set a date and time the challenge will end on
			.SetChallengeMessage("I've challenged you to Tic Tac Toe!") // We can send a message along with the invite
			.Send((response) =>
			{
				if (response.HasErrors)
				{
					Debug.Log(response.Errors);
				}
				else
				{
					//Show message saying sent!;
				}
			});

 

In Java that would be:

    

Map<string, object> data = new HashMap<string, object>();
data.put("@class" : ".CreateChallengeRequest"); //The type of request we're sending
data.put("challengeShortCode" : "ticTacToe"); //The shortcode of the challenge we created on the portal
data.put("endTime" : "2013-12-31T12:00Z"); //When the challenge ends
data.put("usersToChallenge" : "524c13c7e4b0f3abf2b1ddc0"); //The users we want to challenge
Map<string, object> result = gamesparksApi.send(data); //Send our request

   

Similarly, to list all running challenges and get information from them your ListChallengeRequest() in Unity looks like:

  

new ListChallengeRequest().SetShortCode("ticTacToe") //List all challenges with the shortcode "ticTacToe"
			.SetState("RECEIVED") //We only want to get games that we've received
			.SetEntryCount(50) //We want to pull in the first 50 we find
			.Send((response) => //The data we want is stored in the response
			{
				foreach (var challenge in response.ChallengeInstances)
				{
					string challengeId = challenge.ChallengeId;
				}
			}

  

In Java it would look like:

  

Map<string, object> data = new HashMap<string, object>();
data.put("@class" : ".ListChallengeRequest"); //List all challenges
data.put("shortCode" : "ticTacToe"); //with the shortcode "ticTacToe"
data.put("state" : "Running"); //Retrieve currently running games
data.put("entryCount" : 100); //Grab the first 100 we find
Map<string, object> result = gamesparksApi.send(data); //Send our request, the data we want is stored in the result.

  

Hope that helps,

Shane

Thanks for your reply, I am Java Developer, and i dont have any knowledge of C#, please let us know, when Java guides and tutorials will be available?

HI ,

I am newer with this and want to any demo or sample for android development .Please share link or any reference.

Login to post a comment