Code: Select all
function Running:draw()
if self.paused then
self:draw_pause()
self:draw_hud()
return
end
self:draw_game()
end
1. Add this if statement into the draw() call and check every render request if we are paused and decided what to draw based on that.
2. In the pause handler change the draw function of `self` to draw only pause stuff, and when the unpause, change it only to call `draw_game`.
I suppose we perform more useless operations checking every frame whether we are paused which we can simply avoid by directing the code what to draw exactly. This should increase performance. I couldn't find any Lua or LuaJIT documentation about this, unfortunately.