playdate.graphics.getDrawOffset() returns 0, 0 when in sprite :draw() call

Hopefully this issue is pretty self-explanatory - if an example is needed for some reason, I can provide it.

I noticed while trying to do some slightly advanced draw operation (cropping a parallax background to a level's bounds) that my call to getDrawOffset() was returning 0, 0 when the level's bounds was clearly somewhere else (8500, -500) - so if the getDrawOffset() was correct, my level shouldn't have been centered on-screen like it was.

Getting suspicious, I added a second call to getDrawOffset() from within my scene's "update" call, which is called from playdate.update(), and indeed the correct values are returned from there.

In theory this should be easy to reproduce using a basic sprite with draw call and another call from playdate.update as a control. Let me know if you want such an example provided.

This is the screenshot from my console where you can see the same print(gfx.getDrawOffset()) returning different values from within the same tick. I double checked that there are no conflicting calls to setDrawOffset from within the same tick.

And I confirm that a work-around (storing the draw-offset values while in the update() function and then retrieving them from the sprite's draw method gets the right values, unlike calling getDrawOffset() from in the sprite directly.

A sprites draw function is its own draw context. so the draw offset is correctly 0, 0 right?
I haven’t tried, but I would guess that if you use gfx.pushContext and call gfx.getDrawOffset() it will also return 0, 0 while in that context, unless you call setDrawOffset

1 Like

Yep @DraperDanMan, that's exactly what happens. I guess if it's intended, then I have trouble imagining actual use cases for it :slight_smile: