-
abhishekLikes 1Problem Description
hi..
i want to provide a feature for the user to save a screenshot of the current screen.
I am using cocos2d-x v3.0 and c++, and am implementing this feature for the first time.
I did some googling and found this piece of code:
Size screenSize = Director::getInstance()->getWinSize();
RenderTexture * tex = RenderTexture::create(screenSize.width, screenSize.height);
tex->setPosition(screenSize.width/2, screenSize.height/2);
tex->begin();
this->getParent()->visit();
tex->end();
tex->saveToFile("Image_Save.png", Image::Format::PNG);
But i dont know if i am on the correct path. I tried calling this piece of code on button press event but nothing happened.
I tried this in iOS, but i want the feature on iOS and Android. Any help will be very much appreciated.
Thanks
-
Sonar Systems adminLikes 0
This is some code from one of our games that should be easily modifiable for yours:
//Capture Screen Shot __String* imageName = __String::createWithFormat("slot%dscreenshot.png",slotNumber); ToggleTemplate(true); utils::captureScreen(CC_CALLBACK_2(LevelEditorGrid::afterCaptured, this),imageName->getCString()); void LevelEditorGrid::afterCaptured(bool succeed, const std::string& outputFile) { }
-
Sonar Systems adminLikes 0
Check this post out for more info http://www.sonarlearning.co.uk/questions.php?question-topic=197
Login to reply