So I'm working on a game which has multiple characters whose stats can be modified, so I built this test to see if I could store said stats in webstorage.
Capx here: dl.dropboxusercontent.com/u/23727205/webstoragetest.capx
What I'm doing is spawning a random instance from the family 'animal'. Every animal has an attack and speed number. When the layout starts it looks for an entry in webstorage, and if there isn't one it tries to default the values to 1 so that their display bars are the right width.
If you clear webstorage and keep restarting the layout sometimes the attack and speed values are 0, so the bars have 0 width and the saved value ends up being 0 which for our intent and purpose is invalid. I can't for the life of me figure out why. I have a quick fix event in there that checks if they're 0 and sets to 1 but I feel that isn't robust enough. For starters, the initial value is already set to 1 in the family instance variable properties. Shouldn't it default the values?
I ended up having to hard code an instance variable called 'name' in order to display the correct instance name. ideally i wanted to be able to reference the specific name on spawn by calling animal.name to set the text but apparently i don't have access to it through the family. is there another way?