emptyIDs for tilemap get repeated

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.


local tiles = {}
for tileID = 1, 24*40 do
	table.insert( tiles, tileID)

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)

playdate.graphics.sprite.addWallSprites( tilemap, emptyTileIDs )

function playdate.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

The source image tiles-table-10-10.png

And how the collisions are shown in the simulator


Good catch, I was trying to figure out why a tile id > 256 wasn't working for me and this explains it.

1 Like

I hit the same issue the other day and it's really a show stopper :frowning:

1 Like

I'm having the same issue. Please fix this! This is very important with using tools like LDtk and such.

1 Like

I have a fix for this that I think is looking good, we'll try to get it into the next SDK update!


The fix for this issue has released in 1.12.0! Thanks for the fix everyone!