Hi Ed,
Just a simple question. I’m using the memory and fps meters while developing my current app but I don’t want them visible all of the time. I currently call them up using a keypress, but would like to remove them by pressing the same key. How easy would it be to add a remove function for them?
I have the following code in my main.lua which is used to create the meters
local isSimulator = "simulator" == system.getInfo( "environment" ) if isSimulator then -- Show FPS & Memory meters local function debugKeys( event ) local phase = event.phase local key = event.keyName if phase == "up" then if key == "f" then ssk.meters.create\_mem( {allowDrag=true} ) ssk.meters.create\_fps( {allowDrag=true} ) end end end Runtime:addEventListener( "key", debugKeys ) end
How about a hide feature? Destroying and re-building them may not work well, but hiding them should be no prob.
-Ed
Hiding them would be perfect. I’ll admit I hadn’t even thought of that option 
I’ll add a ‘toggle’ feature to both meters, but for now you can modify the code you have as follows:
-
Open meters.lua
-
Locate the meter group (each meter has its own)
function public.create_fps( allowDrag ) local fpsMeter = display.newGroup() – THIS IS THE METER GROUP FOR FPS METER
-
Add this key listener (choose your own key for the toggle event)
function public.create_fps( allowDrag ) local fpsMeter = display.newGroup() – Toggle when h is pressed function fpsMeter.key( self, event ) if( event.keyName == “h” and event.phase == “up” ) then self.isVisible = not self.isVisible end end listen( “key”, fpsMeter )
Awesome. Thanks so much Ed. Works like a charm.
How about a hide feature? Destroying and re-building them may not work well, but hiding them should be no prob.
-Ed
Hiding them would be perfect. I’ll admit I hadn’t even thought of that option 
I’ll add a ‘toggle’ feature to both meters, but for now you can modify the code you have as follows:
-
Open meters.lua
-
Locate the meter group (each meter has its own)
function public.create_fps( allowDrag ) local fpsMeter = display.newGroup() – THIS IS THE METER GROUP FOR FPS METER
-
Add this key listener (choose your own key for the toggle event)
function public.create_fps( allowDrag ) local fpsMeter = display.newGroup() – Toggle when h is pressed function fpsMeter.key( self, event ) if( event.keyName == “h” and event.phase == “up” ) then self.isVisible = not self.isVisible end end listen( “key”, fpsMeter )
Awesome. Thanks so much Ed. Works like a charm.