Help Needed on Webstorage

Discussion and feedback on Construct 2

Post » Wed Feb 12, 2014 6:46 pm

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: https://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.

MAIN ISSUE

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?

SECONDARY ISSUES
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?
B
6
Posts: 2
Reputation: 368

Post » Tue Feb 18, 2014 4:25 pm

FIXED: Just had to remove the 'On Start of Layout' clause from the event.

Although I'm still unsure why the default values for the family instance variable aren't being inherited.
B
6
Posts: 2
Reputation: 368


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 23 guests