I am an amateur programmer attempting to make an adventure game and I need a little help. The basic setup is a panoramic engine that loads external swf’s when you click on a specific area. I need a way to globally store the states of the puzzle variables so that you can save your progress.The basic idea for my save game class is as follows:
- This class is instantiated in the main document class
var saveGame:SaveGame = new SaveGame();
which loads the inventory, music, and swfLoader classes.
- I have 2 arrays in which one stores the variable name, and one stores the var data.
gameVarArray:Array //Variable name
gameVarData:Array //Variable data
- I then use a public method to add a new variable
addGameVar(vName:String, vValue:Object)
which loads vName into gameVarArray and vValue into gameVarData with respective indices. I also use a getVar(vName) and setVar(vName, vValue) methods to retrieve and change variable values.
- I then use a “SharedObject” to dump these arrays to a local file for later retrieval.
My questions are these:
- Is this a good way to store global puzzle variables for a game?
- How do I implement the method in the external swf’s. (when i put saveGame.getVar(vName) on the external swf timeline, it says that it is accessing an “undefined property saveGame”).
I would greatly welcome any help, this is definitely pushing my understanding of OOP.