Game Development Reference
In-Depth Information
PlayerData
. Be sure to click on the
Save as type
option below the filename and
select the
XML
option.
Next, we will create the
EnemyData
XML file. Open a new file in Notepad++, and
add these lines to your new XML file:
As you can see in the preceding screenshot, this new XML file has a similar structure
to that of the
PlayerData
XML file. Our root node is
eData
, and after that, we have
an enemy node. The enemy node holds the rest of the nodes that we save to and
load from almost like a class or object. You can consider the enemy to be a class
and the child nodes within it as the class's properties. The reason we are doing this
is to save multiple enemies to our XML file, and they will each have their own data.
Finally, save this file in the same way you did the
PlayerData
XML file, but name
this one
EnemyData
. I have placed both of these files to the desktop for testing pur-
poses. Normally, you would keep your saved files in the same directory as your game
or in some hidden location.