[Cocos2d-x] Cocos2d-x game screenshots

Source: Internet
Author: User
Most of the time, our games may need to be shared to Weibo or some communities. If the shared content is only some text, the effect may not be very good, if you can add a game to the shared content, it will be very nice. For example, if you catch a big shark in the fishing talents and win the first place in the cool run, I believe that the game screen for that moment is very precious to you. so, I

Most of the time, our games may need to be shared to Weibo or some communities. If the shared content is only some text, the effect may not be very good, if you can add a game to the shared content, it will be very nice. For example, if you catch a big shark in the fishing talents and win the first place in the cool run, I believe that the game screen for that moment is very precious to you. so, I

Most of the time, our games may need to be shared to Weibo or some communities. If only some text is shared, the effect may not be very good.

The game is very nice. For example, if a fisherman catches a big shark and wins the first place in the cool run, I believe that the game screen for that moment is very precious to you. so, how can we

Extract the current game image and run the Code directly:


Void YourClassName: SaveScreenshot () {CCSize size = CCDirector: sharedDirector ()-> getWinSize (); CCRenderTexture * texture = CCRenderTexture: create (int) size. width, (int) size. height); texture-> setPosition (ccp (size. width/2, size. height/2); texture-> begin (); CCDirector: sharedDirector ()-> getRunningScene ()-> visit (); texture-> end (); texture-> saveToFile ("screenshot.png", kCCImageFormatPNG );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.