Monday, March 11, 2013

JSON and the boolean medusa

John had provided blessed silence - added a mute button.  Just one thing tho - state was not being saved from scene to scene.

I figured since I had grasped that nettle before it would be a fairly straight forward task to add the mute state to the other options that were also being kept.

And as we all know, the road to hell is paved with good intentions...

It all started so simply.  I wasn't sure if the Corona SDK JSON module would save anything but a value inside quote marks - the typical "this is a string".  So I started out using "true" and "false" as values in the save state for muting a scene.

Uh oh - John was using the value as a boolean.  Snap.  That's when I thought to see if the JSON routine would save it as a value without the quote marks - and was happy to see that it would.  Awesome.

Except - when going thru the game - the file would get saved with quote marks and errors would get thrown.

Poor Medusa...


Several hours later I removed all the places where I was writing the value wrapped in quotes - and happy day it worked.  So - level one and two have the code that saves the state and sets the mute button based on the state value when the scene starts up.

A couple of housekeeping measures this week too.  Added boss ship movement and shooting to level 2.  The boss shooting had been in the code - just wasn't getting fired due to a small type in the function call.  Level 2 uses different planes from level 1 - and I randomized hits to the enemy planes, you have a 1 in 2 chance of making a fatal hit.

Oh - Professor Jia had suggested our team create a poster for the final presentation:


No comments:

Post a Comment