游戏截屏

CCSize size = CCDirector::sharedDirector()->getWinSize();
 CCRenderTexture* in_texture = CCRenderTexture::create((int)size.width, (int)size.height,kCCTexture2DPixelFormat_RGBA8888);
 in_texture->getSprite()->setAnchorPoint( ccp(0.5f,0.5f) );
 in_texture->setPosition( ccp(size.width/2, size.height/2) );
 in_texture->setAnchorPoint( ccp(0.5f,0.5f) );
 in_texture->begin();
 CCScene* scene = CCDirector::sharedDirector()->getRunningScene();
 CCNode* node;
 CCArray* childs = scene->getChildren();
 for (int i=0; i< scene->getChildrenCount();i++)
 {
  node = (CCNode*)childs->objectAtIndex(i);
  node->visit();
 }
 /*this->visit();*/
 in_texture->end();
 CCLog("%d",in_texture->saveToFile("share.png",kCCImageFormatPNG));

你可能感兴趣的:(游戏截屏)