Player Stats

About

This template expands your game with a stats system allowing your player to see his progress. Also he / she can achieve ingame medals. The names are localised, so you can manage diffrent languages easily. To get help with the language stuff, please see this documentation.

Download

You can download the template at scirra.com

[creativ_button url=”#” icon=”download-alt” label=”Player Stats” colour=”blue” colour_custom=”” size=”medium” edge=”rounded” target=”_blank”]

Screenshots

Medals detail view called when the user clicks any medal. All currently unlocked medals and their name and progress.

Demo

You also can play the demo available on Scirra Arcade.

[creativ_button url=”https://goo.gl/vZ7TCL” icon=”” label=”Player Stats (Demo)” colour=”green” colour_custom=”” size=”medium” edge=”rounded” target=”_blank”]

Used addons

All used plugins are available for free, you’ll find those also included in the package. Here is a list showing all used addons.

Plugins

For the both plugins board and square tx, made by rexrainbow, I recommend you to use his plugin / behavior download tool. Find out more here.

Behaviors

Functions

Here you find all information for the used functions.

Stats

All stats relevant functions.

Stats.Add()

Parameter

  • Param(0): StatsKey (string)
  • Param(1): Value to be added (int)

This function will add the passed value (Param(1)) to the passed state key (Param(0)). Afterwards the stats dictionary will be saved to the LocalStorage automatically.

Stats.setHighest()

Parameter

  • Param(0): StatsKey (string)
  • Param(1): Value to be set as highest (int)

This function will set the value of the passed stats key (Param(0)) only to the passed value (Param(1)) if this passed value is higher than the currently stored one. This fits the most for HighScores or highest reached level. Afterwards the stats dictionary will be saved to the LocalStorage automatically.

Stats.InitBoard()

Parameter

  • none

This function will be called automatically, there is no need to call this function. However it inits the size of the grid for the medal view window.

Stats.GetMedal()

Parameter

  • Param(0): stats key (string)

This function will returned the highest achieved medal for the passed stats key (Param(0)). Following return values are possible.

Return values

  • 0 = no medal achieved yet
  • 1 = bronze
  • 2 = silver
  • 3 = gold

The medal animation frame will then be set to the returned medal (0 based index).

Stats.GetNextTarget()

Parameters

  • Param(0): stats key (string)
  • Param(1): current medal (int, 0-based index)

This function will return the next target to unlock the next medal. This function will be used to display the next target for the detail view window.

Return value

  • int, next target to reach

 

Stats.Show()

Parameter

  • none

This function will show the panel with the currently unlocked medals. Moreover the current amount for each medal, as well as the name, are displayed.

 

Updated on May 2, 2018
Was this article helpful?

Related Articles

Not the solution you were looking for?
Click the link below to submit a support ticket
Visist our Forum!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.