Cocos2d-x 3.0final 终结者系列教程17-屏幕截图后跳转到另外场景

void HelloWorld::jumpToGameOver(){   

//    //保存图片

    Size visibleSize=Director::getInstance()->getWinSize();

//    //定义一个屏幕大小的渲染纹理

    RenderTexture* renderTexture = RenderTexture::create(visibleSize.width, visibleSize.height , Texture2D::PixelFormat::RGBA8888);

    Scene* curScene = Director::getInstance()->getRunningScene();

//    //渲染纹理开始捕捉

    renderTexture->begin();

//    //绘制当前场景

    curScene->visit();

//    //结束

    renderTexture->end();

//    //保存png

    renderTexture->saveToFile("screenshoot.png", Image::Format::PNG);

 //多么通的领悟,害我调了2小时,如果不暂停,下面代码就会报错,

//说Node正在工作,你打断他了,感觉来了加个pause ,success!!

    curScene->pause();

    //跳转到GameOver

    Director::getInstance()->replaceScene(GameOver::createScene());

}

你可能感兴趣的:(node,cocos2dx)