It looks like you're new here. If you want to get involved, click one of these buttons!
OptionsScene = Core.class(Sprite) function OptionsScene:init() local optionsbg = Bitmap.new(Texture.new("images/cartoon_cat-800x600.jpg", true)) optionsbg:setAnchorPoint(0.5, 0.5) optionsbg:setPosition(conf.width/2, conf.height/2) self:addChild(optionsbg) local optionsHeading = TextField.new(conf.fontMedium, "Options") optionsHeading:setPosition((conf.width - optionsHeading:getWidth())/2, 100) optionsHeading:setTextColor(0xffff00) self:addChild(optionsHeading) local backText = TextField.new(conf.fontMedium, "Back") backText:setTextColor(0xffff00) local backButton = Button.new(backText) backButton:setPosition((conf.width - backButton:getWidth())/2, conf.height - 50) backButton:addEventListener("click", function() sceneManager1:changeScene("start", conf.transitionTime, conf.transition, conf.easing) end) self:addChild(backButton) self:addEventListener(Event.KEY_DOWN, function(event) if event.KeyCode == KeyCode.BACK then sceneManager1:changeScene("start", conf.transitionTime, conf.transition, conf.easing) end end) end |
Settings = Core.class() function Settings:init() --our Initial Settings local settings = { username = "Player", } --Check if Settings changed self.isChanged = false --loading settings if exist self.sets = dataSaver.load("|D|settings") if (not self.sets) then self.sets = {} end for key, val in pairs(settings) do if self.sets[key] == nil then self.sets[key] = val self.isChanged = true end end end |
Likes: Holonist
Comments
so where exactly does it crash? desktop or device?
And are there any specific errors with crash?
In your code I see settings initialization, but there is no saving part there
Likes: FaustoM
The code was something similar to this but I must had changed something without noticing because it is working now...
OptionsScene.lua
I am testing with Gideros Player. Should the username remain when I restart or open a new Gideros Player windows? The username is always "Player". It retains the changes from scene to scene but when I restart or open it again it is gone
Thanks a lot in advance. I really appreciate the time you are taking to read this wall of text and reply.
http://appcodingeasy.com/Gideros-Mobile/Save-and-load-data-module-for-Gideros-Mobile
About the player name not updating between restarts, I think you have a typo:
you're saving changes on "|D|setttings" but loading "|D|settings".
Likes: Holonist
Here you will have to check if the file exists first
Unlike datasaver, here everytime we attempt to save/load something, the complete object gets read/overwritten, instead of single attributes. So here you have to decide between simplicity and speed. Though in my opinion, dataSaver never makes a noteable difference, unless you're working with HUGE tables (10k+ entries). And in the end, even datasaver has to rewrite the whole txt file anyway.
If you want to encrypt your savegames with the same method, have a look at
http://giderosmobile.com/forum/discussion/5625/simple-savegame-encryption#Item_1
You can add me on Skype (theholonist) if you like