Adding Score to a Game

Still struggling with adding a “Score” and “HighScore” in my game…Can anybody help me with some sample examples …Please help me if any one can…Please please … [import]uid: 82446 topic_id: 19612 reply_id: 319612[/import]

This is already possible so not really a feature request, unless you are trying to suggest some kind of new API? (If so, please elaborate.)

To show a score you would do newText and update it with the current score value each time points were scored.

For a highscore you would simply save the first score on gameover then in the future compare the current score to the highscore and if greater save the new highscore.

Peach :slight_smile: [import]uid: 52491 topic_id: 19612 reply_id: 75757[/import]

I am extremely sorry for the mistake that I have done.I should have posted this in Game Development Forum.Should i re post it on Game Development Forum? [import]uid: 82446 topic_id: 19612 reply_id: 75766[/import]

@Peach :help me with the score.I have tried CWL then I discovered that it is Third party Tool and I am not getting help from their side.Now, I am discovering “Ice” so that i can use it.Can you help me in other way to the “Scoring System”.?Please help me so that I can add it in my game…Please Help me… [import]uid: 82446 topic_id: 19612 reply_id: 75769[/import]

@ rahulsingh2k10

Dont worry about re-posting this Topic I think peach will move it to the proper place. As for your question, the answer peach gave you is basically all there is to it. Ill post useful links below for you to check out. Peach has a great tutorial on this which ill post below and you can definitely find some similar question on the forums if you search or code exchange. But truly all there is to this is as Peach said you write a text (number) and update the score when player gains score according to your game. Once game over you save the score, and for High score you can have a timer or Runtime check if the new score is higher then the previous score and save the new high score.

Peach Tutorial: http://techority.com/2011/01/26/how-to-add-a-score-to-your-iphone-app/

Very helpful website: http://www.LearningCorona.com/ [import]uid: 30314 topic_id: 19612 reply_id: 75771[/import]

@ LeivaGames: Thanks for the Help.You know that at first I had used that same thing in my scoring that Peach have provided in techority.I was Facing a problem that when the Game got over and i wanted to restart or go to menu page I got error.So, i thought of going to other ways.Now what I am using is Ice .if you can help me on that…please… [import]uid: 82446 topic_id: 19612 reply_id: 75773[/import]

@ rahulsingh2k10

I havent used ICE before but do you just need help on saving or updating the score too? Since you have not posted any code is a bit hard to know what you got done so far regarding your question. For example is your scored being updated already as the player gains score? Or you need help updating the score and saving it or just saving it? [import]uid: 30314 topic_id: 19612 reply_id: 75778[/import]

As of now I can do score update and score saving.even Highscore is working fine.But the only thing that is not happening is the score is not being displayed while playing.Moreover I cant set different Highscore for different levels since I am doing that using ICE .Can you suggest me any other way out for doing all the thing without using ICE? [import]uid: 82446 topic_id: 19612 reply_id: 75786[/import]

@ rahulsingh2k10

Well you seem to be getting somewhere, how are you able to tell score is working properly if its not displaying while playing are you using prints? or it displays if you not playing? If you took the route using ICE might be best post some code for people to see and land you a hand including myself because by posting some of your code we can see what you doing wrong or suggest changes ect. As for suggestion what to use truly im not sure it depends which one you feel comfortable with im sure there are lots of help in this topic. I just use my own method which is basically what peach suggested earlier I display and update the score and once game over I save it then when you check score you can load the saved scores (values) and when you high score basically check if current score greater then previous score and if so then replace it with current score. Its a bit late where I am 3.16 A.M if you have not solve this later on ill give you some samples on how I do it. Keep us updated if you run into problems or solve it.

Best of Luck,
LeivaGames [import]uid: 30314 topic_id: 19612 reply_id: 75787[/import]

Please provide me some sample if you can so that it can make me understand better…Thanks for helping me out. [import]uid: 82446 topic_id: 19612 reply_id: 75797[/import]

have you tried js.lua it handles high scores and saving and loading u can get it from code exchange or www.j-strahan.com [import]uid: 7911 topic_id: 19612 reply_id: 75800[/import]

you can use beebegame class and save high score with no headache)
its pretty simple to use, just download it from code sharing here http://developer.anscamobile.com/code/

and do this:
[lua]game = require( “beebegames” )
local high = game.loadValue(“score.data”)
–it will load your score data and if there’s no such file than it will create one[/lua]
and when you want to save this highscore with comparing it to --current score you can write this
[lua] if score > tonumber(high) then
game.saveValue(“score.data”, score)
end[/lua]

and you can display highscore like this in another scene(if youre using Director Class:
[lua] local high = game.loadValue(“score.data”)

local highScore = display.newText("HighScore: ",0,0,nil, 20)
highScore.x = display.contentWidth/2; highScore.y = display.contentHeight - 30

highScore.text = "HighScore: "… high[/lua] [import]uid: 16142 topic_id: 19612 reply_id: 75801[/import]

I’m going to be a ornery antagonist.

These libraries are great and all and their developers put plenty of effort into doing things to make our lives easy… but …

Keeping score, displaying the score, and tracking high scores are fundamental to every game. Its a basic skill and one every developer needs.

If you are a new developer wanting to make games, you need to roll your own score system and not depend on libraries to do it. Later on, once you’re programming skills are better, then a library can save you time, but its not a short cut a new programmer should take.

Its a good way to learn various things about the api, like the string.format() api call. Its a good way to practice putting text on the screen. And the math is uber simple and the logic for high scores is some of the most basic you can program.

If you can’t manage these, you’re going to have a hard time managing other aspects of your game.

Just sayin! [import]uid: 19626 topic_id: 19612 reply_id: 75835[/import]

+1 rob [import]uid: 7911 topic_id: 19612 reply_id: 75838[/import]

A little late to get back here but I wanted to let you know I’ll be posting some stuff about this on Techority sometime in the next few days, aimed at new users. (Of course!)

It’s written in a similar way to Beebe’s games class, however it is exclusively for saving and loading, none of the other fancy stuff.

Peach :slight_smile: [import]uid: 52491 topic_id: 19612 reply_id: 75901[/import]

+1 robmiracle

I was forced to learn some Sqlite when I finish my first app months back to be able to save and lock levels its very important to learn this basic skills as they become extremely important in future apps. Once you learn the basics is a lot easier to understand libraries and sample codes.

What darkconsoles suggested (beebegames class) its pretty good too I used it to save when my level was completed into a text file and then load the last level completed and unlock all the levels before that level. In other words thats how i locked and unlocked my levels works well.

It seems peach will once again help out people who are fairly new to this so keep checking her page!

Happy Holidays [import]uid: 30314 topic_id: 19612 reply_id: 76078[/import]

Thanks Leiva - I certainly hope to help!

Happy Holidays :slight_smile: [import]uid: 52491 topic_id: 19612 reply_id: 76123[/import]

@rahulsingh2k10
contact me at graffitiPS [@] gmail ~.~ c?m i have a question [import]uid: 7911 topic_id: 19612 reply_id: 76162[/import]

can someone post the direct link for beegame code ? [import]uid: 6134 topic_id: 19612 reply_id: 98292[/import]

Romeo, if you are only after the saving/loading elements you may find this easier: http://techority.com/2012/01/13/easy-saving-of-highscore-in-corona-sdk-apps/

Else, Jon’s Games Class: http://jonbeebe.tumblr.com/post/2320935925/beebegames-class-for-corona-sdk

Peach :slight_smile: [import]uid: 52491 topic_id: 19612 reply_id: 98421[/import]