ios - cocos 2d x捕获屏幕截图并在ios c++中立即显示

标签 ios cocos2d-x

我想在游戏中捕获屏幕截图,并在应用程序上显示捕获的图像,我正在使用cocos 2d-x v2.3 c ++版本。
怎么可能呢?
请帮我
谢谢

最佳答案

您可以使用CCRenderTexture捕获屏幕截图,以下为代码:

CCRenderTexture* texture = CCRenderTexture::create((int)visibleSize.width, (int)visibleSize.height);
texture->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
texture->begin();
CCDirector::sharedDirector()->getRunningScene()->visit();
texture->end();
texture->saveToFile("screenshot.png", kCCImageFormatPNG);

但是我不知道如何从这里检索图像:)如果有人知道,也请告诉我。

关于ios - cocos 2d x捕获屏幕截图并在ios c++中立即显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24341987/

相关文章:

ios - 单元测试时的 Swift 和 Obj-c 互操作性问题

ios - 如何让 SwiftUI 全屏显示?

ios - 如何创建 .sks 文件以在 spriteKit 应用程序中使用

ios - 找不到 CocoaLumberjack.h 文件?

c++ - Action 后释放新对象

c++ - Cocos2d-x - 了解在屏幕上定位 Sprite

ios - iOS 最佳免费崩溃报告器

c++ - 使用 CCNotficationCenter 传递数据

c++ - cocos2dx 中的重写函数

android - Cocos2D-x 示例应用程序在启动时崩溃