Hey Karai17, amazing library! Just had one question. I'm a little confused on how to get tile properties to work. I have seen the other questions posted earlier about tile properties but nothing has fixed our issue. Basically all I want to do is iterate through the tiles and sort ones with certain tiled properties.
Here are is the code I have so far
Code: Select all
function findSolidTiles(layer, collider)
local collision_tiles = {}
local half_tiles = {}
local tw = map.tilewidth
local th = map.tileheight
for y=1, map.height do
for x=1, map.width do
local cur_tile = map.tiles[y]
local tx, ty
tx = (x - 1)
ty = (y - 1)
if layer.data[y][x] == 1 then
-- when I try and access the properties is when I run into an issue. They always return nil
print(cur_tile.properties)
local ctile = collider:addRectangle((tx)*16,(ty)*16,16,16) --adds collision to the tile
--down here I plan to assign different colliders depending on the tile
ctile.type = "solid"
collider:addToGroup("tiles", ctile)
collider:setPassive(ctile)
table.insert(collision_tiles, ctile)
else
end
end
end
return collision_tiles
end
Most of this works but accessing the properties does not.
If you could help me out that would be much appreciated! I know this kind of question has been asked before so I apologize if im just overlooking some simple solution. Overall this is a wonderful library thanks for taking the time to code it!