cocos3.8屏幕截图

utils::captureScreen(CC_CALLBACK_2(HelloWorld::afterCapture, this), "D:/MyCocosProj/FallDown/Resources/ScreenShot.png");

然后在回调函数

void HelloWorld::afterCapture(bool succeed, const std::string& outputFile)
{
	if (succeed)
	{
		CCLOG("outputFile = %s", outputFile.c_str());
		//显示截图
		Sprite* sp = Sprite::create(outputFile);
		sp->setPosition(ccp(100,100));
		this->addChild(sp);
		sp->setScale(0.25); //放缩
	}
	else
	{
		CCLOG("Capture screen failed.");
	}
}


你可能感兴趣的:(cocos2dx,屏幕截屏)