Game Development Reference
In-Depth Information
To test the flat file save system, open the
SaveHandler
script to change a couple
of values. In the
Update
function, where we check for input, instead of calling
SaveEnemies
and
LoadEnemies
, call
WriteToFile
and
ReadFile
. When you
test the scene, again press
F1
to save. On your desktop, you will see a new file
called
PlayerData
; open it and you should see several lines with numbers. These
numbers are the variables you saved from the game.
If you want to customize your flat file save type and not allow players to easily see or
edit the data, change the extension. Instead of saving it as .
txt
, save it as
.save
or anything you want. If the player tries to open it, the computer won't know how to
open the file, but the game will still be able to use it.