I am using Json and i am encoding the high score in the save method but it doesnt save in to the txt file. What is the problem ? :S
-------------------------------------------
local scoreIndex = HighScore:checkEntry(10)
if scoreIndex <= HighScore:count() then
HighScore:storeEntry(scoreIndex, 40, "NameOfPlayer")
end
HighScore:save("score.txt")
-----------------------------------------------------
function cScoreList:save(fileName)
--****************************************************************
local hsFile = io.open( fileName, "w" )
if hsFile then
local hsContent = json.encode(self.list)
hsFile:write( hsContent )
io.close( hsFile )
end
end
Comments
By default it tries to save to Resource directory, but it's read only, so you can't save there.
You can only save temporary files and persistent files inside Documents directory.
So try HighScore:save("|D|score.txt")
this is what I printed out:
scoreIndex
1
hsFile
file (6161D0C0)
[{"name":"abc","points":300},{"name":"---","points":0},{"name":"---","points":0},{"name":"---","points":0},{"name":"---","points":0},{"name":"---","points":0},{"name":"---","points":0},{"name":"---","points":0},{"name":"---","points":0},{"name":"---","points":0}]
but I find no where btw, how can we read the content above to separate score string?
Ultimate Games on Appstore
Ultimate Games on Google Play
http://www.giderosmobile.com/forum/discussion/2183/code-to-encypt-decrypt-json-data#Item_1
Likes: mertocan
If you save a file with a unique name you could do a system wide search to find it, but on windows (XP) it's usually c:/documents and settings//Local Settings/Temp/gideros
(note) Local Settings is usually hidden so you might need to show hidden / system files to access it.
On Windows 7 I think it's c:/users//App Data/Local/Temp/gideros
and on the Mac (I think) is again under your ~ (home) folder.
Likes: thanhquan1512
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill