Just wanted to share two button handlers that could make your development life a little easier.
Both are defined and registered by-name such that we can call them by defining a “buttonHandler” property on a button with a value of either “drawModeToggleHandler” or “pauseResumeGameHandler”.
Those handlers could be part of the Lime distribution as a set of standard handlers for general use.
[lua]function drawModeToggleHandlerFactory()
local drawModes = {“normal”,“hybrid”,“debug”}
local drawModeIndex = 1
return function(e)
drawModeIndex = drawModeIndex + 1
if(drawModeIndex>3)then drawModeIndex = 1 end
physics.setDrawMode(drawModes[drawModeIndex])
end
end
eventHandlerT[“drawModeToggleHandler”] = drawModeToggleHandlerFactory()
function pauseResumeGameHandlerFactory()
local paused = false
return function(e)
if(paused) then physics.start()
else physics.pause() end
paused = not paused
end
end
eventHandlerT[“pauseResumeGameHandler”] = pauseResumeGameHandlerFactory()[/lua]
Enjoy, Frank. [import]uid: 8093 topic_id: 6962 reply_id: 306962[/import]