Skip to content

Commit

Permalink
Add map:addLayer method
Browse files Browse the repository at this point in the history
This method assumes the player is only going to be creating an object
layer using a name as an argument.
  • Loading branch information
timothymtorres committed Jan 12, 2019
1 parent 99b4974 commit b21679d
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion ldurniat/berry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ function M.new( filename, tilesetsDirectory )
end
end

local function createTile(tile, layer) end
--local function createTile(tile, layer) end

for i=1, #data.layers do

Expand Down Expand Up @@ -859,6 +859,31 @@ function M.new( filename, tilesetsDirectory )

end

------------------------------------------------------------------------------------------------
--- Add an object layer by name.
--
-- @param name The name of layer to add.
-- @return The added layer.
------------------------------------------------------------------------------------------------
function map:addLayer( name )

local layer = display.newGroup()

layer.name = name

-- These are the defaults
layer.properties = {}
layer.type = 'objectgroup'
layer.alpha = 1
layer.isVisible = true
layer.offset_x = 0
layer.offset_y = 0
layer.objects = {}

self:insert( layer )

end

------------------------------------------------------------------------------------------------
--- Find the layer by name.
--
Expand Down Expand Up @@ -892,6 +917,7 @@ function M.new( filename, tilesetsDirectory )
-- @param layer The layer to add the object to.
-- @return The added displayObject.
------------------------------------------------------------------------------------------------
map.createObject = createObject

------------------------------------------------------------------------------------------------
--- Find the objects by name and type.
Expand Down

0 comments on commit b21679d

Please sign in to comment.