1 #include "cocos2d.h"
2 using namespace cocos2d;
3 class CCScreenshot : CCObject
4 {
5 public:
6 // static std::string screenshotPathForFile(const char* fileName);
7 static CCRenderTexture* screenshotWithStartNode(CCNode* startNode,const char* fileName);
8 };
9
10
11
12 #include "CCScreenshot.h"
13
14 /*std::string CCScreenshot::screenshotPathForFile(const char* fileName)
15 {
16 return fileName;
17 }*/
18 CCRenderTexture* CCScreenshot::screenshotWithStartNode(CCNode* startNode,const char* fileName)
19 {
20 CCDirector::sharedDirector()->setNextDeltaTimeZero(true);
21 CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
22 CCRenderTexture* rtx = CCRenderTexture::create(visibleSize.width,visibleSize.height);
23
24 rtx->begin();
25 startNode->visit();
26 rtx->end();
27
28 std::string path;
29 path = CCFileUtils::sharedFileUtils()->getWritablePath();
30 path+= fileName;
31
32 rtx->saveToFile(std::string(path).c_str());
33
34 return rtx;
35 }