functionCapture(isPNG, width, height, ...) local nodes = {...} if #nodes == 0thenreturnend
-- 创建RenderTexture local screen if isPNG then screen = cc.RenderTexture:create(width, height, cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888, gl.DEPTH24_STENCIL8_OES) else screen = cc.RenderTexture:create(width, height) end screen:beginWithClear(0, 0, 0, 0) -- 遍历节点 for _, node inpairs(nodes) do node:visit() end screen:endToLua()
-- 保存文件 screen:saveToFile("img_path", isPNG and cc.IMAGE_FORMAT_PNG or cc.IMAGE_FORMAT_JPEG, isPNG) end