Creating a scoreboard
You can create scoreboards from the API settings page for your game and go to the Scoreboards section. A game can have multiple scoreboards. For example, you might have a different scoreboard for each game mode.
You can choose among various sorting and formatting options for your scoreboard. For example, an arcade game will sort by number of points, ranking higher scores at the top. But a racing game will sort by overall time, with smaller times being better.
Submitting a score
To submit a score, use the API.postScore method:
import com.newgrounds.*;
// submit a score of 400
API.postScore("Score Board Name", 400);
The score must be an integer. The format of the score depends on the Score Format set on the scoreboard settings page.
- If your scoreboard is set in Simple format, submit the score as is.
- If your scoreboard is set to Decimal, Currency, or Metric Distance format, then submit the score multiplied by 10. 4123 would be a score of 41.23.
- If your scoreboard is set to Time format, then submit the time in milliseconds. 123456 would become 2:03.45.
- If your scoreboard is set to Distance format, then submit the distance in inches. 1234 would become 102' 10".
Each user that posts a score will be displayed once on the scoreboard. Only the user's highest score is remembered; lower scores are discarded. A user must be logged-in on Newgrounds to submit a score.
Displaying scores
You can use the Score Browser component to display the high scores. If you are using Flash, copy and paste the Score Browser component to the stage and enter your scoreboard name into the component parameters.
You can also create the Score Browser component using ActionScript:
import com.newgrounds.components.*;
var scoreBrowser:ScoreBrowser = new ScoreBrowser();
scoreBrowser.scoreBoardName = "Score Board Name";
scoreBrowser.period = ScoreBoard.ALL_TIME;
scoreBrowser.loadScores();
addChild(scoreBrowser);
Follow the instructions on using the API Components for more info on how to use the API components.
Also see the Scoreboard reference page.