I'd love the option to set a flag on an individual sprite to force it to always redraw. This would mirror the global sprite.setAlwaysRedraw(flag)
with a sprite:setAlwaysRedraw(flag)
.
My use case is a simple stopwatch sprite. It only needs to draw when the timer isn't paused. I could avoid the need for an update function to mark it dirty every frame and keep the logic entirely internal to the class if I could just toggle an always redraw flag for the sprite when pausing/unpausing the timer.
For example:
function Stopwatch:start()
self.timer:start()
self:setAlwaysRedraw(true)
end
function Stopwatch:pause()
self.timer:pause()
self:setAlwaysRedraw(false)
self:markDirty() -- draw one last frame to make sure the final time is drawn
end
function Stopwatch:draw()
font:drawText(string.format("%05.2f", self:elapsedTime() / 1000):gsub("%.", ":"), 0, 0)
end