static CCString ScreenShoot()
{
	CCSize size = CCDirector::sharedDirector()->getWinSize();  
	//定义一个屏幕大小的渲染纹理  
	CCRenderTexture* pScreen = CCRenderTexture::create(size.width,size.height, kCCTexture2DPixelFormat_RGBA8888);  
	//获得当前的场景指针  
	CCScene* pCurScene = CCDirector::sharedDirector()->getRunningScene();  
	//渲染纹理开始捕捉  
	pScreen->begin();  
	//当前场景参与绘制  
	pCurScene->visit();  
	//结束捕捉  
	pScreen->end();  
	char szfile[1024]={0};
	//string   pathToSave = "/sdcard/download/";//

	string pathToSave = "ScreenShoot.png";
	//sprintf(szfile,"%s%s",pathToSave.c_str(),"share.png");
	//保存为png
	if(pScreen->saveToFile(pathToSave.c_str(), kCCImageFormatPNG))
	{
		//CCMessageBox("saveToFile ok!", "saveToFile ok!");
	}
	pathToSave = CCFileUtils::sharedFileUtils()->getWritablePath()+pathToSave;
	//保存为jpg
	//pScreen->saveToFile("XXXXXX.jpg", kCCImageFormatJPEG);  
	CC_SAFE_DELETE(pScreen); 

	return pathToSave.c_str();
}
Пример #2
0
void AsMessageBox::initShareMessageBox(int subType){
    
    if(!MainUser->muted)
        CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("openFrame.wav");
    
    shareImageIndex = subType;
    
    //1.截屏
    if (subType == 1) {
        CCRenderTexture* pScreen = CCRenderTexture::create(winSize.width,winSize.height);
        CCScene* pCurScene = CCDirector::sharedDirector()->getRunningScene();
        pScreen->begin();
        pCurScene->visit();
        pScreen->end();
        pScreen->saveToFile("shared.png",kCCImageFormatPNG);
    }

    //2.黑色底层
    cover = CCLayerColor::create(ccc4(0,0,0,200));
    cover->setPosition(CCPointZero);
    addChild(cover,0);
    
    //3.提示框底层
    showbox = CCSprite::createWithSpriteFrameName("shareFrame.png");
    showbox->setScaleY(1.1);
    showbox->setPosition(ccp(size.width/2,size.height/2+winDif*2*alpha));
    cover->addChild(showbox,1);
    
    //4.提示框上的文字
    CCSprite* shareWeixinSprite = CCSprite::createWithSpriteFrameName("shareWeixin.png");
    CCSprite* shareWeixinSprite_s = CCSprite::createWithSpriteFrameName("shareWeixin-s.png");
    CCSprite* shareWeixin1Sprite = CCSprite::createWithSpriteFrameName("shareWeixin1.png");
    CCSprite* shareWeixin1Sprite_s = CCSprite::createWithSpriteFrameName("shareWeixin1-s.png");
    CCSprite* closeSprite = CCSprite::createWithSpriteFrameName("closeMatchTable.png");
    CCSprite* closeSprite_s = CCSprite::createWithSpriteFrameName("closeMatchTable-s.png");
    CCMenuItemSprite* closeItem = CCMenuItemSprite::create(closeSprite,closeSprite_s,this,menu_selector(AsMessageBox::closeMessageBox));
    CCMenuItemSprite* item1 = CCMenuItemSprite::create(shareWeixinSprite,shareWeixinSprite_s,this,menu_selector(AsMessageBox::goShare));
    CCMenuItemSprite* item2 = CCMenuItemSprite::create(shareWeixin1Sprite,shareWeixin1Sprite_s,this,menu_selector(AsMessageBox::goShare));
    item1->setTag(10);
    item2->setTag(11);
    item1->setPosition(ccp(size.width*18/50,size.height*10/20+winDif*2.18*alpha));
    item2->setPosition(ccp(size.width*32/50,size.height*10/20+winDif*2.18*alpha));
    closeItem->setPosition(ccp(size.width*5.7/7,size.height*11.5/20+winDif*2.18*alpha));
    closeMenu = CCMenu::create(item1,item2,closeItem,NULL);
    closeMenu->setPosition(CCPointZero);
    addChild(closeMenu,2);
    
    //5.文字提示
    CCLabelTTF* shareToIndiLabel = CCLabelTTF::create("分享给朋友","Arial Rounded MT Bold",24);
    CCLabelTTF* shareToCircleLabel = CCLabelTTF::create("分享到朋友圈","Arial Rounded MT Bold",24);
    shareToIndiLabel->setColor(ccc3(55, 55, 55));
    shareToCircleLabel->setColor(ccc3(55, 55, 55));
    shareToIndiLabel->setPosition(ccp(size.width*18/50,size.height*8/20+winDif*2.18*alpha));
    shareToCircleLabel->setPosition(ccp(size.width*32/50,size.height*8/20+winDif*2.18*alpha));
    addChild(shareToIndiLabel,7,53);
    addChild(shareToCircleLabel,7,54);
    
}
Пример #3
0
void Player::hit() {
    if (getSprite() == NULL) {
        return;
    }
	CCSize size = CCDirector::sharedDirector()->getWinSize();
    Config::isPause = true;
	CCRenderTexture* renderTexture = CCRenderTexture::create(size.width, size.height);
	CCScene* temp = CCDirector::sharedDirector()->getRunningScene();
	renderTexture->begin(); 
	temp->visit();
	renderTexture->end();
	CCDirector::sharedDirector()->pushScene(GamePause::scene(renderTexture));
//	if (m_scene != NULL) {
//		Config::score++;
//		m_scene->setScore();
//	}
}