cocos2dx 3.4 截图代码

    Size size = Director::sharedDirector()->getWinSize();  
    //定义一个屏幕大小的渲染纹理  
    RenderTexture* pScreen = RenderTexture::create(size.width,size.height, kCCTexture2DPixelFormat_RGBA8888);  
    log("-------log1---");
    //获得当前的场景指针  
    Scene* pCurScene = Director::sharedDirector()->getRunningScene();  
    //渲染纹理开始捕捉  
    pScreen->begin(); 
    //当前场景参与绘制  
    pCurScene->visit();  
    //结束捕捉  
    pScreen->end();  
    //保存为jpg
    pScreen->saveToFile("test.jpg", kCCImageFormatJPEG);  

    string path=FileUtils::getInstance()->getWritablePath();
    log("---------path=%s",path.c_str());

 

posted @ 2015-07-24 17:42  冷夜 - 网游编程技术  阅读(347)  评论(0编辑  收藏  举报