When drawing tilemap with a sourceRect and drawOffset, it behaves differently from how a simple image is drawn. I built a minimal example that shows this: minimal-example.zip (17.4 KB)
The loop shows how drawOffset and sourceRect work in isolation and together. I would expect that the third part would combine effects of both, but that happens only in case of the image.
-- the third part of the loop combines non-zero drawOffset
-- and non-zero sourceRect origin
gfx.setDrawOffset(x, y)
map:draw(10, 10, x, y, 200, 200)
pic:draw(230, 50, gfx.kImageUnflipped, x, y, 100, 100)
The result in action (the problem occurs when the counter in top right is in between 200 and 299):
The tilemap cancels both steps out, probably because drawOffset is applied both onto the tilemap and its tiles in some way. (When I set a different value for offset and drawRect origin, it’s visible that both offset and drawRect are applied.)
Credit: This behavior was discovered by @edzillion on Squad Discord, I was just trying to explain… and then debug