Scoring Module Help

Okay, I desperately need scores or a scoring module explained to me… I’m finding it so difficult to wrap my head around it and truth be told I have no idea what I’m doing when it comes to scores and there seems to be barely any good tutorials out there!! 

I need the gameOver scene to display a score and a high score, that is all, I’m sure I’m finding it waaaay more difficult than it should be and I’m just messing up my code by trying to experiment…

Thankyou!

Have you read this tutorial?

http://coronalabs.com/blog/2013/12/10/tutorial-howtosavescores/

Rob

Yes I have read that tutorial. I’m probably just a really slow learner!

So I can use:

local scoreText = score.init({ fontSize = 20, font = "Helvetica", x = display.contentCenterX, y = 20, maxDigits = 7, leadingZeros = true, filename = "scorefile.txt", })

to display the actual score?

It’s mainly saving the highscore on the gameover page that im a bit wobbly with… 

Well the scoring module assumes you’re going to want to show the score during play, which is why it returns a display object of the current score.  If you only want to show the score at the end, I would create the object in your main.lua and hide it by setting it’s .isVisible flag to false.  You would need to make it globally available (don’t use real globals, but see this tutorial:  http://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/))

Then in your end of game score, you could make it visible and position it where you want.  Then just increment the score as necessary.

Rob

Okay that sounds like it should be fine. In terms of showing the highest score that the player achieved every time the user opens the app?? Is that similar to this?

Farid

The score module should handle saving the high score between sessions.

Rob

Have you read this tutorial?

http://coronalabs.com/blog/2013/12/10/tutorial-howtosavescores/

Rob

Yes I have read that tutorial. I’m probably just a really slow learner!

So I can use:

local scoreText = score.init({ fontSize = 20, font = "Helvetica", x = display.contentCenterX, y = 20, maxDigits = 7, leadingZeros = true, filename = "scorefile.txt", })

to display the actual score?

It’s mainly saving the highscore on the gameover page that im a bit wobbly with… 

Well the scoring module assumes you’re going to want to show the score during play, which is why it returns a display object of the current score.  If you only want to show the score at the end, I would create the object in your main.lua and hide it by setting it’s .isVisible flag to false.  You would need to make it globally available (don’t use real globals, but see this tutorial:  http://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/))

Then in your end of game score, you could make it visible and position it where you want.  Then just increment the score as necessary.

Rob

Okay that sounds like it should be fine. In terms of showing the highest score that the player achieved every time the user opens the app?? Is that similar to this?

Farid

The score module should handle saving the high score between sessions.

Rob