首页 文章

Corona sdk上的捕捉屏幕

提问于
浏览
4

我尝试了很多方法来使用电晕sdk来捕捉屏幕,我读了http://docs.coronalabs.com/api/library/display/captureScreen.html

Corona: how to capture a screen in corona?

然而,当我运行该程序时,Corona sdk冻结并且我不得不关闭它我正在使用Corona SDK for windows,有时我得到“运行时错误R6025 PURE虚函数调用”,我尝试了很多与其他人一起工作的示例代码是我的代码

_W = display.viewableContentWidth
_H = display.viewableContentHeight
local background = display.newRect(0, 0, 320, 480);
background:setFillColor(255,255,255);
local foo = display.newImageRect("images/foo.png",100,100);
foo.anchorX=0.5
foo.anchorY=0.5
foo.x = _W * 0.5;
foo.y = _H * 0.5;
local screenShot = display.captureScreen(true);
foo:removeSelf();
background:removeSelf();
screenShot.xScale = 0.5;
screenShot.yScale = 0.5;
screenShot.rotation = 45;

这是我的build.settings文件

androidPermissions =    
{
    "android.permission.VIBRATE",
    "android.permission.WRITE_EXTERNAL_STORAGE"
},

2 回答

  • 0

    您也可以尝试使用 display.save 将屏幕保存到文件中 .

    检查Lerg's code这样做

    当按下's'键时,此代码将在模拟器中保存屏幕截图

    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
    
  • 0

    您可以使用display.save()函数来保存来自作为函数的第一个参数传递的给定显示组的屏幕截图

相关问题