No worries, I realised putting my query on the end of this topic might mean it would be buried.. but I thought it might end up being useful to others.
Thanks for clarifying. I think that's where I was getting confused. As you said, the only thing your plugin is concerned with is the collidable property exported from Tiled. Everything else I was trying to do with other types of collisions is outside of that and really is what Bump is concerned with. I've managed to handle both cases a bit cleaner in the following code:
Code: Select all
-- override playerFilter function
local playerFilter = function(item, other)
local kind
-- if the object of the collision has a properties table
-- (ie. it's been exported from Tiled with the collidable custom property)
if other.properties ~= nil then
kind = other.properties -- store a reference to the properties table to use with the filter
else
kind = other.name -- else store a reference to the object's name since it has no properties table
-- (useful as we can set the 'name' manually or grab it from the object exported by Tiled)
end
if kind.collidable then -- if object.properties table has the collidable element
return 'slide'
elseif kind == 'spring' then -- if object.name is spring
return 'bounce'
elseif kind == 'hotspot' then -- if object.name is hotspot
return 'cross'
end
end -- end of playerFilter function
-- actually move the player, obeying collisons
player.x, player.y, cols, len = world:move(player, player.x, player.y, playerFilter)