GameCenterLeaderboardPostScore

int GameCenterLeaderboardPostScore(char *board_id, int score);

 

Posts the user's score to the specified leaderboard.

 

Return Value

 

Returns one if successful.  Be sure to use the global Game Center callback specified in GameCenterInit() to get results from the Game Center servers.

 

Parameters

 

board_id

Specifies which leaderboard is to be updated.  This value corresponds to the Leaderboard ID field in the list of leaderboards in iTunes Connect.

 

score

specifies the score to be sent to the leaderboard.

 

Remarks

 

GameCenterLeaderboardPostScore() sends the current user's score to the Game Center leaderboard specified.

 

Availability

 

Available in DragonFireSDK 2.0 and later.

 

Example

 

#include "DragonFireSDK.h"

 

const char *ErrorNoError(int value)

{

  if (value)

      return("ERROR! ");

  return("");

}

 

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;

   }

}

 

int OnButton(int id)

{

  switch (id)

   {

  case 1:

       GameCenterAchievementsShow();

      break;

  case 2:

       GameCenterLeaderboardShow();

      break;

  case 3:

       GameCenterAchievementsPost("com.mycompany.myapp.myachievement", 100.0f);

      break;

  case 4:

       GameCenterAchievementsReset();

      break;

  case 5:

       GameCenterLeaderboardPostScore("com.mycompany.myapp.myleaderboard", 100);

      break;

  case 6:

       GameCenterGetLeaderboardRank("com.mycompany.myapp.myleaderboard");

   }

     

  return(id);

}

 

void AppMain()

{

   GameCenterInit(OnGameCenter);

 

   ButtonAdd("Images/Button", 10, 10, OnButton, 1);

   ButtonAdd("Images/Button", 10, 50, OnButton, 2);

   ButtonAdd("Images/Button", 10, 90, OnButton, 3);

   ButtonAdd("Images/Button", 10, 130, OnButton, 4);

   ButtonAdd("Images/Button", 10, 170, OnButton, 5);

   ButtonAdd("Images/Button", 10, 210, OnButton, 6);

}

 

void AppExit()

{

 

}

 

void OnTimer()

{

 

}