本文主要是介绍关于cocos2dx RenderTexture的newImage为空,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Sprite* spr1 = Sprite::create("spr1.png");spr1->retain();//在3.0此处必须写上这个auto render = RenderTexture::create(visibleSize.width, visibleSize.height, Texture2D::PixelFormat::RGBA8888);render->retain();render->beginWithClear(0, 0, 0, 255);spr1->visit();render->end();Director::getInstance()->getRenderer()->render();//在3.0此处必须写上这个,否则newImage整张图片都为黑色,或者在下一帧获取char jpg2[20];sprintf(jpg2, "image-%d.jpg", 123);std::string fullpath1 = FileUtils::getInstance()->getWritablePath() + jpg2;Image* image1 = render->newImage();image1->saveToFile(fullpath1, true); //设置保存目录和文件名image1->release();
这篇关于关于cocos2dx RenderTexture的newImage为空的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!