cocos2dx-lua 截屏

– 直接上代码
function layer:shotScene()
local callBack = function (isS,outFile)
if isS then
local sceneImage = self.rootNode:getChildByName(“scene_image”)
if sceneImage == nil then
sceneImage = ccui.ImageView:create()
sceneImage:loadTexture(outFile)
sceneImage:setPosition(640,360)
sceneImage:setName(“scene_image”)
sceneImage:setScale(0.5)
self.rootNode:addChild(sceneImage)
end
– self.updateBtn:loadTextureNormal(outFile)
print(“截图成功”)
cc.FileUtils:getInstance():removeFile(outFile)
else
print(“截图失败”)
end
end
local fileName = “screenshot”…tostring(os.time())…".png"
–c++自带方法
cc.utils:captureScreen(callBack,fileName)
end

发布了2 篇原创文章 · 获赞 0 · 访问量 160

猜你喜欢

转载自blog.csdn.net/lynn807961674/article/details/91417753