|
-
- -- 截屏
- -- callback = function(fullPath, fileName)
- function ScreenShot(callback)
- local dateNow = os.date("*t", os.time())
- local timeString = string.format("%04d-%02d-%02d-%02d%-02d-%02d-%03d", dateNow.year, dateNow.month, dateNow.day, dateNow.hour, dateNow.min, dateNow.sec, math.random(100, 999));
- local fileName = "screenshot_"..tostring(timeString)..".jpg"
- local filePath = cc.FileUtils:getInstance():getWritablePath()..fileName
-
- cc.FileUtils:getInstance():screenToFile(filePath, function(ret)
- if 1 == tonumber(ret) then
- if callback then
- callback(filePath, fileName)
- end
- else
- if callback then
- callback()
- end
- end
- end );
- end
-
- -- 截屏并展示给玩家看
- function showScreenShot()
- ScreenShot(function(fullPath, fileName)
- if fullPath and fileName then
- local view = import("luaScript.Views.Room.ScreenView"):new(fileName)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- else
- showTooltip("截图失败");
- end
- end)
- end
|