HOW DO YOU SAVE HIGH SCORES!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 11
- Joined: Mon Jan 16, 2012 10:40 am
HOW DO YOU SAVE HIGH SCORES!
In the making of the game galactic gauntlet the academy shows you basically everything except how to save the high scores. So my question is HOW DO YOU DO IT?
thanks in advance for any help.
thanks in advance for any help.
Re: HOW DO YOU SAVE HIGH SCORES!
There is a great tutorial LiveCode Lessons | How To - Step-By-Step Guides To Tasks In LiveCode | How do I save custom properties in a standalone application?
http://lessons.runrev.com/s/lessons/m/4 ... pplication
on saveHighestScore
## where are we?
if the cSkin of card "gamecard" is "spaceskin" then
put "balloonskin" into tCard
else
put "spaceskin" into tCard
end if
## Is the current score the highest?
put fld "scorefield" into tCurScore
put the cMaxScore of card tCard into tMaxScore
if tCurScore > tMaxScore then
## play some flourish sound
answer "Your"&& tCurScore && "is the highest score!"
##save the new highest (maximum) score as a property of the skin we are in
set the cHighScore of card tCard to tCurScore
end if
end saveHighestScore
http://lessons.runrev.com/s/lessons/m/4 ... pplication
on saveHighestScore
## where are we?
if the cSkin of card "gamecard" is "spaceskin" then
put "balloonskin" into tCard
else
put "spaceskin" into tCard
end if
## Is the current score the highest?
put fld "scorefield" into tCurScore
put the cMaxScore of card tCard into tMaxScore
if tCurScore > tMaxScore then
## play some flourish sound
answer "Your"&& tCurScore && "is the highest score!"
##save the new highest (maximum) score as a property of the skin we are in
set the cHighScore of card tCard to tCurScore
end if
end saveHighestScore
Re: HOW DO YOU SAVE HIGH SCORES!
So now I'm doing the lesson, following the directions, and getting an error message that it can't find the stack I've created after saving it as a standalone. I created the launcher, the main application, put this handler in the stack script of the launcher:
on openStack
open stack "Main Application.livecode"
close stack "Launcher"
end openStack
The error message is:
stack "Untitled 1": execution error at line 5 (Chunk: can't find stack), char 4
Line 5 is blank. The last line is line 4.
It must be the path problem. Anyone done it?
on openStack
open stack "Main Application.livecode"
close stack "Launcher"
end openStack
The error message is:
stack "Untitled 1": execution error at line 5 (Chunk: can't find stack), char 4
Line 5 is blank. The last line is line 4.
It must be the path problem. Anyone done it?
-
- Posts: 90
- Joined: Thu Dec 08, 2011 12:21 pm
Re: HOW DO YOU SAVE HIGH SCORES!
hey all,
just wanted to throw in my 2 cents here because the topic interested me and I was looking to do the same thing. I tried Spencer's code and it did not work at first. Thank you for putting it up Spencer because had you not i wouldn't have been able to do the following. This code works. It not only sets the high score but will not deliver the message until the high score is beaten. My suggestion is, before you run the script to make sure it works, go into your gamecard (whatever it's called) and right-click (on the card itself) > card and stack > card property inspector. From the drop down menu click "Custom Properties". Click the "+" symbol to add a custom property called "cHighScore" (without quotes). Once it's added click in the window underneath labelled "property contents" and type "0" in just the first line (wouldn't recommend pressing "enter" as this adds another line to the contents of the property). Once that's done, save all work and run the script. Should work properly. I've include where you activate the handler as well as the handler itself below:
Hope this helps anyone who was looking to do this in a basic form. It took me 2 hours of tweaking the code to finally, and I mean FINALLY get the code to function properly. I hope others benefit from this, however much. Feedback welcome
I would like to clarify that I am not currently using any skins in my game, therefore the cSkin section mentioned above did not apply to me. However, if you ARE using skins you would need to include what Spencer wrote above:
therefore, in total, if you have skins it would look like this:
I am going to try and figure out how to code something that displays the top high scores, when I do i'll post it here
just wanted to throw in my 2 cents here because the topic interested me and I was looking to do the same thing. I tried Spencer's code and it did not work at first. Thank you for putting it up Spencer because had you not i wouldn't have been able to do the following. This code works. It not only sets the high score but will not deliver the message until the high score is beaten. My suggestion is, before you run the script to make sure it works, go into your gamecard (whatever it's called) and right-click (on the card itself) > card and stack > card property inspector. From the drop down menu click "Custom Properties". Click the "+" symbol to add a custom property called "cHighScore" (without quotes). Once it's added click in the window underneath labelled "property contents" and type "0" in just the first line (wouldn't recommend pressing "enter" as this adds another line to the contents of the property). Once that's done, save all work and run the script. Should work properly. I've include where you activate the handler as well as the handler itself below:
Code: Select all
on stopGame
put false into sMoving
set the layer of group "gameoverscreen" to top
show group "gameoverscreen"
saveHighScore
end stopGame
on saveHighScore
put "gamecard" into tCard
if the cHighScore of card tCard = 0 then
put field "scorefield" into tHighScore
set the cHighScore of card tCard to tHighScore
answer "You got the highest score: " & tHighScore
end if
if the cHighScore of card tCard > 0 then
put field "scorefield" into tCurrentScore
if tCurrentScore > the cHighScore of card tCard then
answer "You got the highest score: " & tCurrentScore
set the cHighScore of card tCard to tCurrentScore
end if
end if
end saveHighScore
I would like to clarify that I am not currently using any skins in my game, therefore the cSkin section mentioned above did not apply to me. However, if you ARE using skins you would need to include what Spencer wrote above:
Code: Select all
if the cSkin of card "gamecard" is "spaceskin" then
put "balloonskin" into tCard
else
put "spaceskin" into tCard
end if
Code: Select all
on saveHighScore
if the cSkin of card "gamecard" is "spaceskin" then
put "balloonskin" into tCard
else
put "spaceskin" into tCard
end if
if the cHighScore of card tCard = 0 then
put field "scorefield" into tHighScore
set the cHighScore of card tCard to tHighScore
answer "You got the highest score: " & tHighScore
end if
if the cHighScore of card tCard > 0 then
put field "scorefield" into tCurrentScore
if tCurrentScore > the cHighScore of card tCard then
answer "You got the highest score: " & tCurrentScore
set the cHighScore of card tCard to tCurrentScore
end if
end if
end saveHighScore
-
- Posts: 43
- Joined: Mon Oct 15, 2012 6:44 pm
Re: HOW DO YOU SAVE HIGH SCORES!
this my sample for a puzzle game when i test it on android physical device the check sign hide on open card
please help me to fix that problem .
please download the file and fix the problem
please help me to fix that problem .
please download the file and fix the problem
How do you save high scores?
Please, guys. Keep this forum neat and tidy. Don't use all caps in the title of your subject.
Mark
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode