At the end I overcome the problem of trigger tiles with this code:
function process_trigger_tiles(main_tilemap_url, triggers_tilemap_url)
* Create the "_triggers" layer in your main tilemap and put in all tiles
that you want to affect with a trigger collisionobject
* Create the another tilemap, the "triggers tilemap", and bring it into your collection
and link to it a trigger collisionobject
* Create in the triggers tilemap two layers:
> "bounds" : will only allow us to expand the bounds of this tilemap to match or to be greater
than the main tilemap. For this purpose put some tiles on this layer.
> "triggers" : this layer will be filled with all the "_triggers" layer tiles from the main tilemap.
tilemap.set_visible(main_tilemap_url, "_triggers", false)
tilemap.set_visible(triggers_tilemap_url, "bounds", false)
copy_tilemap_layer(main_tilemap_url, "_triggers", triggers_tilemap_url, "triggers")
function copy_tilemap_layer(src_tilemap_url, src_tilemap_layer, dest_tilemap_url, dest_tilemap_layer)
-- IMPORTANT NOTES:
-- 1. This function only works with already created source and destination tilemap and layers!
-- 2. It is assumed that both tilemaps share the same tilesource.
-- 3. Make sure that the source tilemap bounds are at least equal or contained in the destination tilemap!
-- Otherwise you will get the "Could not set the tile since the supplied tile was out of range." error!
local bx, by, bw, bh = tilemap.get_bounds(src_tilemap_url)
for y=by, by+bh-1 do
for x=bx, bx+bw-1 do
local id = tilemap.get_tile(src_tilemap_url, src_tilemap_layer, x, y)
if id ~= 0 then -- avoid nil tiles
tilemap.set_tile(dest_tilemap_url, dest_tilemap_layer, x, y, id)
I hope can be useful for someone!
For the other special tiles will use the suggested approach… scan and based on the id of the tile doing stuff! =)
Thank you for all your help!