In a simple test, when
setDrawOffset is used to pan the "camera" around a simple scene, and
Image:draw(x, y, flip, sourcex, sourcey, w, h) is used to draw a small portion of a sprite sheet, the effect is to pan around within the source image, but always draw in the same location on screen. That doesn't seem useful. Adding the offset to both the location and
sourceRect seems to make it do the thing you want, but defeats the purpose of
Here's a demonstration, including the (commented) workaround:
local gfx = playdate.graphics local ox = 0 local oy = 0 local sheet = gfx.image.new("pokemonoverworldspriteslarger") function playdate.update() if playdate.buttonIsPressed(playdate.kButtonLeft) then ox -= 1 elseif playdate.buttonIsPressed(playdate.kButtonRight) then ox += 1 end if playdate.buttonIsPressed(playdate.kButtonUp) then oy -= 1 elseif playdate.buttonIsPressed(playdate.kButtonDown) then oy += 1 end gfx.setDrawOffset(ox, oy) gfx.clear() -- A simple rect moves around as expected: gfx.drawRect(178, 98, 68, 67) -- Image with sourceRect: drawOffset seems to affect `sourceRect`, not `x` and `y`; -- a different portion of the image is drawn, but always at the same fixed location sheet:draw(180, 100, gfx.kImageUnflipped, 124, 64, 64, 63) -- Workaround: add the offset to both the location and sourceRect: -- sheet:draw(180+ox, 100+oy, gfx.kImageUnflipped, 124+ox, 64+oy, 64, 63) end
I grabbed that sprite sheet randomly here
Testing on macOS with pdc and simulator 1.9.0 (132294).
Note: in the context of my game, the behavior is less clear, with the rendered portion of the image clipping and jumping around in an unpredictable way. I'm hoping this simple demonstration is enough to identify the problem (or my misunderstanding) but I can try to reproduce the stranger behavior if necessary.