Time for action – implementing loading and saving
In the Tile Engine project, open the
TileMap.vb
module file.Add the Loading and Saving Maps region to the
TileMap
module:#Region "Loading and Saving Maps" Public Sub SaveMap(fileToSave As FileStream) Dim formatter As BinaryFormatter = new BinaryFormatter() formatter.Serialize(fileToSave, mapCells) fileToSave.Close() End Sub Public Sub LoadMap(fileToLoad As FileStream) Try Dim formatter As BinaryFormatter = new BinaryFormatter() mapCells = CType(formatter.Deserialize(fileToLoad),MapSquare(,)) fileToLoad.Close() Catch ClearMap() End Try End Sub Public Sub ClearMap() For x As Integer = 0 To MapWidth - 1 For y As Integer = 0 To MapHeight - 1 For z As Integer = 0 To MapLayers - 1 mapCells(x, y) = New MapSquare(2, 0, 0, "", True) Next Next Next End Sub #End Region
Back in the Level Editor project, open the
MapEditor
form in Design mode.Double...