Corona SDK Pro Tip of the Day #24
Changing FPS dynamically

Did you know that you can invoke almost any arbitrary code inside config.lua? We can use it to read a txt file and set fps according to it's content. That way users can switch fps from in game settings.

Here is such config.lua

local fps = 60  
local path = system.pathForFile('fps.txt', system.DocumentsDirectory)  
local file = io.open(path, 'r')  
if file then  
    local content = file:read('*a')
    if content == '30' then
        fps = 30
    elseif content == '60' then
        fps = 60
    end
    io.close(file)
end

application = {  
    content = {
        width = 320,
        height = 480,
        scale = 'letterbox',
        fps = fps,
        imageSuffix = {
            ['@2x'] = 1.2
        }
    }
}

Notice fps variable. It has default value of 60, you can change it. If there is fps.txt file inside Documents directory, then it is read and fps changed to either 30 or 60.

In your app/game you can incorporate a settings scene with a slider or a button that changes FPS. Once user changes the setting, write the value to fps.txt and ask user to restart the app/game.

You can programmatically exit with

if app.isAndroid then  
    native.requestExit()
else  
    os.exit()
end  

Indie Game Developer