Additional way to do debug draw from anywhere in code

Currently there's playdate.debugDraw() which draws in the set colour.

I'd like to request alternative interfaces, where I can add to the debug draw layer from anywhere in my code.

Suggestions

  • gfx.lockDebug()/unlockDebug() or gfx.pushDebug()/popDebug() similar to lockFocus or pushContext
    • any drawing operations done in between would draw to the debug layer

The goal would be to debugdraw from alongside my game logic code by changing some function names, so quick changes, rather than have to write a bunch of logic in debugDraw to draw sprites or shapes.

6 Likes

My workaround for this:

  1. create a full screen blank image:
overlay = gfx.image.new(playdate.display.getWidth(), playdate.display.getHeight(), gfx.kColorBlack)
  1. draw to that in white from anywhere in your code
gfx.pushContext(overlay)
	gfx.setColor(gfx.kColorWhite)
	gfx.setLineWidth(1)
	gfx.drawCircleAtPoint(x,y,r)
gfx.popContext()
  1. then a simple debugdraw to draw the overlay once!
function playdate.debugDraw()
	overlay:draw(0,0) -- draw our layer of collected debug draws
	overlay:clear(gfx.kColorBlack) -- blank for next update
end
5 Likes