ATL has been updated to version 0.11.0. There's been a couple of substantial changes. They unfortunately will break current code.
FIrst off, map.tileLayers and map.objectLayers are now combined into one table called map.layers. This is simpler and it's a preliminary move to get ready for the new image layers coming in Tiled 0.9.0. I didn't think 3 different tables for looking up layers was a very good idea so they got combined.
To tell them apart they now remember their class name. So to iterate over all TileLayers in a map you now do this:
Code: Select all
for name, layer in pairs(map.layers) do
if layer.class == "TileLayer" then
-- do something
The second major change is that the functionality of tileData is now built into TileLayers themselves. Basically any operation you did on tileData is now just done on the TileLayer (so tileLayer.tileData:iterate() is now just tileLayer:iterate(). The most common operations in ATL is done on tiles so this change saves a step and makes it look nicer.
Another change is that there is a new map.__call() function that will return the layer by name. So map("ground") is the same as map.layers["ground"].
All of these changes together simplifies the operation on tiles.
Code: Select all
-- Old way of iterating over tiles
for x, y, tile in map.tileLayers["ground"].tileData:iterate() do
-- New way of iterating over tiles
for x, y, tile in map("ground"):iterate() do
The last substantial change is the introduction of custom layers. Custom layers are layers that the user defines and is inserted into the map. The name is entirely an abstraction. Any table can be used as a custom layer and, in fact, custom layers were used before this version. To use them before you only had to have a table with a draw() function and insert it into the map's drawList (Now renamed layerList). Even though this was practically necessary to make a game with ATL it wasn't obvious at all. Now there is an interface for doing it.
Along with this, map.callback() has been created. This function will forward callbacks to all layers if the functions exist. This is intended to forward love callbacks to custom layers but you can trigger your own callbacks as well.
Code: Select all
-- Create a new custom layer
local layer = map.newCustomLayer("LayerName")
layer.time = 0
-- Update the layer
self.time = self.time + dt
-- Draw the layer
love.graphics.print("It has been " .. self.time, 0, 0)
-- Forward the update callback to the map
-- Draw the map
-- map:draw is now a shortcut for map:callback("draw").
Here is a list of changes. Let me know if you have any questions.
- Renamed Map.drawList to Map.layerOrder.
- Renamed Map.drawPosition to Map.layerPosition.
- Combined Map.tileLayers and Map.objectLayers into one table - Map.layers.
- The functionality of tileData is now combined with TileLayer.
- Changed Map.__call to return layers by their name.
- Created Map.callback() to forward love callbacks to layers.
- Created Map.swapLayers()
- Created Map.newCustomLayer() which is a new interface for creating custom layers.
- Classes now remember their class name.
- Removed object movement functions to deter the use of objects other than reading data from.
- Removed the fixPO2 option for the loader.
- Generally cleaned up the code and made it easier to read.
- Properties are now automatically converted into proper types (numbers, boolean, string) when loaded.
- Readme file changed. There is now a new VERSION.txt file for version information.