-- in main.lua (or wherever) consider creating a global instance of Spectacle.
spec = Spectacle({font = "fonts/font-rains-1x", line_height = 1.4, lines = 3, background=playdate.graphics.kColorWhite})
-- so elsewhere you can simply use:
spec:watchFPS()
spec:watchMemory()
spec:watch(game_state, "player.x")
spec:watch(self, "camera.x", "cam")
spec:watch(function()
if self.player.is_jumping then
return "JUMPING"
else
return "GROUNDED"
end
end, "state")
-- or use the built-in graphing:
spec:graphFPS({min=1, max=50})
spec:graph(function()
return math.random(1, 100)
end, {type="line", min=1, max=100, period=0.1, name="Random"})
-- and instead of print():
spec:print("hello", "world", val1, val2)
-- and finally, make sure you draw.
spec:draw(x, y)
-- you may also want to toggle it on/off.
playdate.getSystemMenu():addCheckmarkMenuItem("debug", spec.visible, function(value)
spec.visible = value
end)
Note: Be sure to check watch() and graph() functions for documentation on their supported options.
Just replace my old debug system with this and love it! would only recommend to add an option to change the position where it's drawn, already changed it on my game
I had draw(x, y) and removed it. Can’t remember why. I think I had this idea of making it more console like where it overlays from the top. Never did it. Hmm, I’ll add it back.
Maybe! I’m working on incorporating my graph method from another little library I shared a year or so back, but allowing you to graph any value in your game over time as part of the same UI: spec:graph(self, “sprite_count”). May make sense to set rect on init so graph has a width to draw to. Maybe?