
Isn't there a Tiled branch with animated tiles? I'm hoping they'll still put that in 0.9.2 and then I can use it instead of my hack. It works for now, though.
Code: Select all
local STI = require "sti"
local map = sti.new("map")
local prop = map.tiles[1234].properties -- select the properties from Tile 1234
If you are using HardonCollider, you can add a few lines in the Map:getCollisionMap function.ochetski wrote:I asked because I did implemented a collision system with STI. But needed to set the tile sizes hard coded, because I wasn't able to get tiles width and height from the map.
My collision system is now ugly, complex and hard to use with multiple entities. I will probably change it to use love.physics. I will share it here as soon as I finish it.
Thanks Karai, please keep the good work because it will bring great games to life.
Code: Select all
function Map:getCollisionMap(index)
local layer = assert(self.layers[index], "Layer not found: " .. index)
assert(layer.type == "tilelayer", "Invalid layer type: " .. layer.type .. ". Layer must be of type: tilelayer")
local w = self.width
local h = self.height
local map = {
type = layer.type,
orientation = layer.orientation,
collision = true,
opacity = 0.5,
data = {},
}
for y=1, h do
map.data[y] = {}
for x=1, w do
if layer.data[y][x] == nil then
map.data[y][x] = 0
else
map.data[y][x] = 1
ctile = collider:addRectangle((x-1)*self.tilewidth, (y-1)*self.tileheight, self.tilewidth, self.tileheight)
collider:setPassive(ctile)
end
end
end
return map
end
Code: Select all
collider = HC(100, on_collision,stop_collision)
Users browsing this forum: No registered users and 3 guests