Skip to content

Instantly share code, notes, and snippets.

@Lerg
Last active November 6, 2022 21:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lerg/8906864 to your computer and use it in GitHub Desktop.
Save Lerg/8906864 to your computer and use it in GitHub Desktop.
Take screenshots in simulator with S key
if app.isSimulator then
Runtime:addEventListener('key', function (event)
if event.keyName == 's' and event.phase == 'down' then
local scene = storyboard.getScene(storyboard.getCurrentSceneName())
if scene and scene.view then
display.save(scene.view, display.pixelWidth .. 'x' .. display.pixelHeight .. '_' .. math.floor(system.getTimer()) .. '.png')
return true
end
end
end)
end
@Lerg
Copy link
Author

Lerg commented Feb 9, 2014

It uses my app.lua

app.isSimulator - just to make sure it doesn't run on devices.

It uses storyboard, you might want to convert it to composer.

Screenshots are saved into the Documents directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment