This is the code i have for the collision detection part.
Code: Select all
function player:isColliding(map, x, y) -- character collides with tile layer solid only from tmx map.
local layer = map.tl["Solid"]
local tileX, tileY = math.floor(x / map.tileWidth), math.floor(y / map.tileHeight)
local tile = layer.tileData(tileX, tileY)
local layer2 = map.tl["Death"]
local tileX, tileY = math.floor(x / map.tileWidth), math.floor(y / map.tileHeight)
local tile = layer2.tileData(tileX, tileY)
return not(tile == nil)
end
Code: Select all
function player:collide(event)
if event == "floor" then
self.y_vel = 0
self.standing = true
end
if event == "ceiling" then
self.y_vel = 0
end
if event == "death" then
self.y_vel = 0
player.x = 256
end
end
PS: i am using advance tiled loader, and looked at their range of in depth tutorials but could not even get the game to compile after the changes.