Game ElementsThis is a featured page

Scoring

A frequent question that comes up is how to handle scoring for a game. There are a bunch of different ways to do it, but the following demonstrates a simple example. If you would like to see a short video of how this is done, go to the videos section and watch "Add High Scores and UI to your Game."


Tracking the Score

world score property

  1. Click on the Astronaut to access the World's class and add a custom property to the world called score. Note that this should be an integer valued property because we don't record fractional high scores.
  2. Create a behavior on an object that fires on the event that you would like it to. In the example below, this happens when one object contacts any other object. In the logic editor, use the "Add" action to add a value to the World's score property. Use whatever value you would like to increment the score.

adding to world score



Displaying the Score

  1. Create a new rectangle that will be used to display the score.
  2. Set it's "filled" attribute to false, or set the "fill color" to the desired color.
  3. Set the "draw border" attribute to false, or set the "border color" to the desired color.
  4. Set the "ignore physics" flag to true.
  5. Add a new behavior to the object.updating score text
    1. Select the "when the property of an object changes."
    2. In the left-hand panel, navigate to the "actors" tab, click on the World, and drag the World's score property into the event you just created.
    3. Click on the "this" tab. Drag the "text" property into the right hand panel.
    4. Navigate back to the World properties and drag the world's score property into the right hand side of the "set" statement (or ctrl-drag the property out of the event "when X is modified" ).


Setting a High Score

set high scoreHigh scores should only be used as the result of end-game scenarios or significant events in the game. You do not want to be sending the high score to the server every time it is incremented.
  1. Create a new behavior for the end-game scenario. Generally this will be the result of losing a certain number of lives, colliding with an enemy, or some other such event.
  2. Drag in the "set high score" action.
  3. Navigate to the Objects tab, and drag in the World' score property to indicate the value that will be set.

Displaying the High Score Menu

The High Score menu allows you to display the end user's high score in relation to all of their friends.

As shown to the right, during the end-game scenario, drag in the "show high scores" action. This action allows you to display the high scores. It also signifies the end of a game, as the only options for where to go from this screen are to restart the application or customize it.


No user avatar
dale.beermann
Latest page update: made by dale.beermann , Jul 24 2009, 3:32 PM EDT (about this update About This Update dale.beermann remove old asset reference - dale.beermann

12 words deleted

view changes

- complete history)
Keyword tags: game score scoring
More Info: links to this page
There are no threads for this page.  Be the first to start a new thread.

Related Content

  (what's this?Related ContentThanks to keyword tags, links to related pages and threads are added to the bottom of your pages. Up to 15 links are shown, determined by matching tags and by how recently the content was updated; keeping the most current at the top. Share your feedback on Wetpaint Central.)