Author Topic: Game Center and Sandobx  (Read 3152 times)

DevPet

  • Guest
Game Center and Sandobx
« on: February 17, 2014, 10:40:13 am »
Hi everyone. I've almost finished developing a game I've been working on for a few months.
Now I'd like to add the game center integration and save the highest score achieved, I've read it's possible to use this "Sandbox" which is a sort of Game Center for testing. Anyone could give more details about?
Where do I find this tool?
Thanks a lot, Pietro (:

expleo

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: Game Center and Sandobx
« Reply #1 on: February 17, 2014, 11:15:08 am »
hi, in short, you need to create a highscore list on iconnect. then dl the provision file and upload to zimusoft. there is a faq somwhere on this site, i will see if I can find it. But tim needs to be around to install a provision file on test build server, so you need assistance.

warning though, after I did this, Any build I try create with a different name all fails, so Im bound to have same name on everything I build, until I upload a new provision file. shouldnt be like tjis, but I gave up after a few tries with support a year ago, not that tim didnt try, but it didnt work. probably I who messed up the provisioning process, never got full "hang" on that

DevPet

  • Guest
Re: Game Center and Sandobx
« Reply #2 on: February 17, 2014, 12:33:09 pm »
Very helpful, thanks a lot. So when I'll be ready I'll contact support. For the same name it's not a deal that big, at least as long as I'm only testing!

Micboy

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-2
    • View Profile
Re: Game Center and Sandobx
« Reply #3 on: February 19, 2014, 04:39:59 am »
To use iTunes Connect for GameCentre integration, do you need to pay $99/year first as an iTunes developer?

Thank you,
Mikey

EricB

  • Jr. Member
  • **
  • Posts: 61
  • Karma: +1/-0
    • View Profile
Re: Game Center and Sandobx
« Reply #4 on: February 19, 2014, 06:52:25 pm »
Yes you need to log into your developers account to set up game center in your app.

expleo

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: Game Center and Sandobx
« Reply #5 on: February 20, 2014, 01:48:31 am »
Ok, and micboy, here are the general steps (as promised on another thread) to add gamecenter.

1) Setup Itunes highscore table. This is pretty easy, you need to create a profile for your game, then a highscore table (youse the suggested approach with reverse domain name and app.. for example, my domain is expleo.no and I make a game pigkiller, i call my list no.expleo.pigkiller.topscrore  (if I want more leaderboards for this game, it might be no.expleo.pigkiller.mostPigsKilled no.expleo.pigkiller.shortestRun etc etc). Each board is pretty straightforward. For this, you need itunes dev account at $100 a year.

2) For testing, you now need to dl the provisionprofile for this game, and send to zimusoft. It will work without this though, so if you are confident everything is ok, it is skippable to test :D

3) In your code, you now need to have a highscrore savefile of sorts. I keep it simple. I have a highscore file with a single 'top' score in it. At appstart, I load this, so I have a variable called highScore.  So if the highscore on file is 500, my highScore variable will be 500. (look up how to load and save files, I pulled my code almost straight from the API doc for this)

4) In my game, I have a 'currentScore' variable that keeps tab of the current players highscore. When game is over,  I check if currentScore is more than HighScore. If it is, I save the new currentScore on file as the new HighScore, and submitt the new score to gamecenter.

5) To test this, you need to have completed step 2, and also need to log out of gamecenter on your device, and create a sandbox gamecenter account (or more). IOS will detect you are running a game in developing, so you don't need to do anything special than having an email adress ready, and registrer your GC account (it is same process as a real registration, but it says sandbox).

6) In my mainscreen I have a simple button that fetches the GC leaderboard, everything is already set up for you, so it is pretty simple actualy.

I will add some code here to explain:

in Main, you need to have:
 GameCenterInit(OnGameCenter);

for the OnGameCenter procedure, copy paste from API doc:

void OnGameCenter(int type,int flag,int value,char *desc)

{

  switch (type)
   {
  case 1: // Authentication
       printf("Authentication event result: %svalue:%d desc:%s\n",ErrorNoError(flag),value,desc);
      break;
  case 2: // Achievements Post
       printf("Achievements Post event result: %svalue:%d desc:%s\n",ErrorNoError(flag),value,desc);
      break;
  case 3: // Achievements Reset
       printf("Achievements Reset event result: %svalue:%d desc:%s\n",ErrorNoError(flag),value,desc);
      break;
  case 4: // Score Post
       printf("Score Post event result: %svalue:%d desc:%s\n",ErrorNoError(flag),value,desc);
      break;
  case 5: // Leaderboard Rank
       printf("Leaderboard Rank event result: %svalue:%d desc:%s\n",ErrorNoError(flag),value,desc);

      break;
   }
}

No need to worry about these if you just make a simple, pretty 'dump' highscore list with no finesse (like mine :) )

ok, I have a subroutine on Button, and one of the buttons (show highscore rank) is case 720. It is as simple as:

   case 721: // get highscore list
      GameCenterLeaderboardShow();
   break;

so just a call to show the leaderboards.

And last, at games end, check if score is more than highscore (insertscore subroutine is almost just a copy paste from zimusofts doc on loading and saving file)

if (FinalScore>scores.totalsScore){
   InsertScore(FinalScore);
   sprintf(tempText,"New High Score !!");
   TextSetText(combatTextInt[1],tempText);
   GameCenterLeaderboardPostScore("no.expleo.pigKiller.highScore", FinalScore);
}

so to sum it up:

GameCenterLeaderboardPostScore to post a score to gamecenter
GameCenterLeaderboardShow(); to get and show the highscore list

and some file save/load with a few variables to keep track of the devices high score.

Probably much more rafined wayt to use it, but keep it simple. This works for me.
« Last Edit: February 20, 2014, 01:50:23 am by expleo »

DevPet

  • Guest
Re: Game Center and Sandobx
« Reply #6 on: February 23, 2014, 04:59:47 am »
Expleo, you've been so helpful. there's just one last thing: Let's say I do want to test the game center before uploading. So I create and download a provisioning profile, but should I check "App Store" or "Ad Hoc" while creating a new App ID? and then, to send the profile to zimusoft I guess it's sufficent to email Tim, Right?
Thanks again.

Micboy

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-2
    • View Profile
Re: Game Center and Sandobx
« Reply #7 on: February 23, 2014, 01:30:00 pm »
Thank you very much Expleo!! :D

Micboy

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-2
    • View Profile
Re: Game Center and Sandobx
« Reply #8 on: February 23, 2014, 01:39:31 pm »
Quick 3 questions expleo:

I don't actually have GameCenter on my iPod so I'm wondering what happens when this function runs: GameCenterLeaderboardShow(). Does a new window open?

Also, my game only allows the scores from 1-10 (variable) and I want to rank the people in terms of the frequency of obtaining this result, e.g Player A obtains score 10 (highest) 12 times (individual plays - so he has played many games and achieved a score of 10, 12 times). Player B obtains a score of 10 also, but only 11 times. (Other players may obtain a score of 9, 23 times, but still not as good as 10). Do GameCenter leaderboards allow this?

Finally, I haven't paid for the developer account yet, but when I do, will I be able to use iTunes Connect, because currently it says that I don't have the rights to do so?

Thank you in advance!!
Mikey

DevPet

  • Guest
Re: Game Center and Sandobx
« Reply #9 on: February 24, 2014, 05:56:27 am »
@Micboy,
Yes, when you'll get your iOS Developer Account account you'll be able to log into iTunes Connect and manage everything about your app, from game center leaderboards, to prices and taxes.

For your leaderboard question, Game Center doesn't allow the ranking with score + frequency, but it only allows a single value to be posted. So I guess you have to decide within your code who is the best player (for example by using an additional and "invisible" score variable which takes into the account both you score [1-10] and the frequency.)
Right now I'm thinking something like:
int score2 = 1000 * score + frequency.
This way, a 10 with a frequency of -say- 5 is still higher then a 9 with a frequency of -say- 23.



 

Micboy

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-2
    • View Profile
Re: Game Center and Sandobx
« Reply #10 on: February 24, 2014, 03:25:42 pm »
Thanks DevPet for that info. Final 2 questions!!

1. Does GameCentre also show local highscores? (I've currently got a file which stores these highscores but showing them in a table will require a bit more tedious coding/graphics design)

2. Is AdMob out of the question?

Thank you very much guys for all your help!!

Michael

expleo

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: Game Center and Sandobx
« Reply #11 on: February 25, 2014, 10:24:51 am »
1) no (I don't think so). gane centre stores one score per user account per score table.

2) dragonfire supports iAd, so that is the way to go for ads. that said, don't bother. really. you need so many downloads for ads to work that you need a top downloaded game. flappy bird was a once in a moon case, for each flappy bird yhere are 10000000 games much better but lost in cyberspace.
« Last Edit: February 25, 2014, 10:37:27 am by expleo »