zoukankan      html  css  js  c++  java
  • cocos2dx for lua 截屏功能

    cocos2dx的utils类中包含截图功能,使用方法如下:

    cc.utils:captureScreen(function(successed,outputFile)--第一个参数是截图成功或者失败的回调函数

            if successed then--如果成功,返回true,否则返回nil

                local sp = cc.Sprite:create(outputFile)

            end

        end,"captureTexture.png")第二个参数是保存文件名

    看cocos源代码,截图文件会将保存在可写路径中或者绝对路径中,

    std::shared_ptr<Image> image(new Image);

            if (image)

            {

                image->initWithRawData(flippedBuffer.get(), width * height * 4, width, height, 8);

                if (FileUtils::getInstance()->isAbsolutePath(filename))

                {

                    outputFile = filename;

                }

                else

                {

                    CCASSERT(filename.find("/") == std::string::npos, "The existence of a relative path is not guaranteed!");

                    outputFile = FileUtils::getInstance()->getWritablePath() + filename;

                }

                succeed = image->saveToFile

    转载请注明出处,from 博客园 HemJohn

  • 相关阅读:
    Java中数据类型的分类
    PL/SQL Developer工具
    Oracle数据库SQL语句的分类
    Oracle数据库控制台常用命令
    关于C#中泛型类型参数约束(where T : class)
    C#动态操作DataTable(新增行、列、查询行、列等)
    ADO.NET 全面整理
    区块链入门教程
    排序算法汇总
    常用SQL
  • 原文地址:https://www.cnblogs.com/HemJohn/p/4873292.html
Copyright © 2011-2022 走看看