It seems there is an issue with the emptyIDs that are passed to getCollisionRects(emptyIDs)
.
An ID get repeated every 256 IDs. So if you set ID 1 as empty, tiles with the ID, 256, 512, etc. will also be set an empty automatically.
Here a simple example that just display a tilemap with only unique ID and if we set only the first tile to be empty, it shows that extra empty tile are also set as empty.
import("CoreLibs/graphics")
import("CoreLibs/sprites")
local tiles = {}
for tileID = 1, 24*40 do
table.insert( tiles, tileID)
end
local emptyTileIDs = {1}
local tilemap = playdate.graphics.tilemap.new()
tilemap:setImageTable( playdate.graphics.imagetable.new( "tiles" ) )
tilemap:setTiles( tiles, 40)
local level = playdate.graphics.sprite.new( )
level:setTilemap( tilemap )
level:moveTo( 0, 0 )
level:setCenter(0, 0)
level:add()
playdate.graphics.sprite.addWallSprites( tilemap, emptyTileIDs )
function playdate.update()
playdate.graphics.sprite.update()
-- playdate.graphics.clear()
-- local collisionRects = tilemap:getCollisionRects( emptyTileIDs )
-- playdate.graphics.setColor(playdate.graphics.kColorBlack)
-- for index, rect in ipairs(collisionRects) do
-- playdate.graphics.fillRect(rect.x*10, rect.y*10, rect.width*10, rect.height*10)
-- end
end
The source image tiles-table-10-10.png
And how the collisions are shown in the simulator