How do you make a scoring system in Corona sdk?

I am trying to figure out how to make a scoring system like the one in Temple Run where it calculates distance. Is there an easy way to do that?

On another note, how would you show your score in a different scene in storyboard? And how would you calculate best score?

Thanks!

You are using storyboard and storyboard is a table that you can use to store scores and other things like a level counter.

Because you start every module with: local storyboard = require (“storyboard”) it is available throughout your game.

insert a table called myData into the storyboard table to use to store your score, level, lives etc…

storyboard.myData = {}

Declare the myData table at the top of your main.lua module only. Your main.lua module should start like this…

local storyboard = require (“storyboard”)
local scene = storyboard.newScene()

display.setStatusBar(display.HiddenStatusBar)

storyboard.myData = {}    – Create a table to save your data to

storyboard.myData.score = 0

storyboard.myData.lives = 3

Now in each module/storyboard scene load the values from storyboard.myData, level one would start like this…

local storyboard = require (“storyboard”)
local scene = storyboard.newScene()

local score = storyboard.myData.score

local lives = storyboard.myData.lives

Use them as you like in your main chunk…

score = score +100

lives = lives - 1

When you exit the scene put the values back into the myData table to be accessed by the next level…

storyboard.myData.score = score

storyboard.myData.lives = lives

Simple as that!

thanks QuizMaster, 

this is very helpful

You are using storyboard and storyboard is a table that you can use to store scores and other things like a level counter.

Because you start every module with: local storyboard = require (“storyboard”) it is available throughout your game.

insert a table called myData into the storyboard table to use to store your score, level, lives etc…

storyboard.myData = {}

Declare the myData table at the top of your main.lua module only. Your main.lua module should start like this…

local storyboard = require (“storyboard”)
local scene = storyboard.newScene()

display.setStatusBar(display.HiddenStatusBar)

storyboard.myData = {}    – Create a table to save your data to

storyboard.myData.score = 0

storyboard.myData.lives = 3

Now in each module/storyboard scene load the values from storyboard.myData, level one would start like this…

local storyboard = require (“storyboard”)
local scene = storyboard.newScene()

local score = storyboard.myData.score

local lives = storyboard.myData.lives

Use them as you like in your main chunk…

score = score +100

lives = lives - 1

When you exit the scene put the values back into the myData table to be accessed by the next level…

storyboard.myData.score = score

storyboard.myData.lives = lives

Simple as that!

thanks QuizMaster, 

this is very helpful