当前位置: 首页>>代码示例>>C++>>正文


C++ CCRenderTexture::begin方法代码示例

本文整理汇总了C++中CCRenderTexture::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ CCRenderTexture::begin方法的具体用法?C++ CCRenderTexture::begin怎么用?C++ CCRenderTexture::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCRenderTexture的用法示例。


在下文中一共展示了CCRenderTexture::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: resizeImage

bool GameUtil::resizeImage(const char* szInFile, const char* szOutFile, int width, int height)
{
	CCLog("GameUtil::resizeImage - [path:%s] [W:%d] [H:%d]", szInFile, width, height);
	CCSprite* pOrg = CCSprite::create(szInFile);
	CCSize orgSize = pOrg->getContentSize();

	float fScaleX = (float)width / orgSize.width;
	float fScaleY = (float)height / orgSize.height;
	float fScale = max(fScaleX, fScaleY);

	CCPoint ptCenter = ccp(width/2, height/2);

	// 세로 사진은 가로로 방향을 변경
	if (orgSize.width < orgSize.height) {
		pOrg->setRotation(90.0f);
		ptCenter = ccp(height/2, width/2);
	}

	CCRenderTexture * rt = CCRenderTexture::create(width, height);
 
	pOrg->setPosition(ptCenter);
	pOrg->setAnchorPoint(ccp(0.5f, 0.5f));
	pOrg->setScale(fScale);
 
    rt->begin();
    pOrg->visit();
    rt->end();
	
	// 파일로 저장
	bool bSave = rt->saveToFile(szOutFile);

	return bSave;
}
开发者ID:faransae,项目名称:Classes,代码行数:33,代码来源:GameUtil.cpp

示例2: ccp

CCRenderTexture * Utils::fontCreateStroke(CCLabelTTF * label,float size, ccColor3B color){
    
    CCRenderTexture *rt = CCRenderTexture::create((int)label->getTexture()->getContentSize().width, (int)label->getTexture()->getContentSize().height);
    CCPoint originalPos = label->getPosition();
    ccColor3B originalColor = label->getColor();
    bool originalVisibility = label->isVisible();

    label->setColor(color);
    
    ccBlendFunc originalBlend = label->getBlendFunc();
    label->setBlendFunc((ccBlendFunc){ GL_SRC_ALPHA, GL_ONE });
    //CCPoint center = ccp(label->getTexture()->getContentSize().width/2 + size, label->getTexture()->getContentSize().height/2 + size); //shadow effect offset
    
    CCPoint center = ccp(label->getTexture()->getContentSize().width/2, label->getTexture()->getContentSize().height/2);
    
    rt->begin();
    
    for(int i = 0; i<360; i+=30){
        label->setPosition(ccp(center.x + sin(CC_DEGREES_TO_RADIANS(i)) * size, center.y + cos(CC_DEGREES_TO_RADIANS(i)) * size));
        label->visit();
    }
    
    rt->end();
    
    label->setPosition(originalPos);
    label->setColor(originalColor);
    label->setBlendFunc(originalBlend);
    label->setVisible(originalVisibility);
    
    rt->setPosition(originalPos);
    
    return rt;
}
开发者ID:madeiras,项目名称:cocos2d-x-general,代码行数:33,代码来源:Utils.cpp

示例3: mergeSprite

CCSprite* GameUtil::mergeSprite(CCSprite* pOrg1, CCSprite* pOrg2)
{
	CCPoint ptOrg1(pOrg1->getPosition());
	CCPoint ptOrg2(pOrg2->getPosition());

	CCRenderTexture * rt = CCRenderTexture::create((int)pOrg1->getContentSize().width, (int)pOrg1->getContentSize().height);
 
	pOrg1->setPosition(ccp(pOrg1->getContentSize().width/2, pOrg1->getContentSize().height/2));
	pOrg2->setPosition(ccp(pOrg2->getContentSize().width/2, pOrg2->getContentSize().height/2));
 
    rt->begin();
    pOrg1->visit();
    pOrg2->visit();
    rt->end();
	
	pOrg1->setPosition(ptOrg1);
	pOrg2->setPosition(ptOrg2);

	CCSprite *retSprite = CCSprite::createWithTexture(rt->getSprite()->getTexture());
	retSprite->setFlipY(true);

	//CCSize sisze1 = retSprite->getContentSize();
	//CCSize size2 = retSprite->getTexture()->getContentSize();

	// debugging : 파일로 저장
	//string sPath = CCFileUtils::sharedFileUtils()->getWriteablePath();
	//sPath.c_str();
	//char szSave[MAX_PATH];
	//sprintf(szSave, "%ssave.png", sPath.c_str());
	//bool bSave = rt->saveToFile(szSave);

	return retSprite;
}
开发者ID:faransae,项目名称:Classes,代码行数:33,代码来源:GameUtil.cpp

示例4: ScreenShoot

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();
}
开发者ID:FreeDao,项目名称:FaceBook-Working--FlappyBird,代码行数:30,代码来源:HelloWorldScene.cpp

示例5: renderScreenShot

void RenderTextureZbuffer::renderScreenShot()
{
	CCRenderTexture *texture = CCRenderTexture::renderTextureWithWidthAndHeight(512, 512);
	if (NULL == texture)
	{
		return;
	}
	texture->setAnchorPoint(ccp(0, 0));
	texture->begin();

	this->visit();

	texture->end();

	CCSprite *sprite = CCSprite::spriteWithTexture(texture->getSprite()->getTexture());

	sprite->setPosition(ccp(256, 256));
	sprite->setOpacity(182);
	sprite->setFlipY(1);
	this->addChild(sprite, 999999);
	sprite->setColor(ccGREEN);

	sprite->runAction(CCSequence::actions(CCFadeTo::actionWithDuration(2, 0),
		                                  CCHide::action(),
		                                  NULL));
}
开发者ID:BGCX261,项目名称:zombieswarmer-svn-to-git,代码行数:26,代码来源:RenderTextureTest.cpp

示例6: PauseGame

//ÔÝÍ£
void CGameControler::PauseGame(int _type){
	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCRenderTexture *renderTexture = CCRenderTexture::create(visibleSize.width,visibleSize.height);
	renderTexture->begin(); 
	this->getParent()->visit();
	renderTexture->end();
	CCDirector::sharedDirector()->pushScene(Gamepause::scene(renderTexture));
}
开发者ID:bo-jwolf,项目名称:Graduation,代码行数:9,代码来源:GameControler.cpp

示例7: initShareMessageBox

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);
    
}
开发者ID:nooboracle,项目名称:ForTest,代码行数:58,代码来源:Type3Share.cpp

示例8: createStroke

    CCRenderTexture* UILabelTTF::createStroke(CCLabelTTF* label, float size ,ccColor3B cor)
    {
        float RealSize = size;
        if(label == NULL || label->getTexture() == NULL)
        {
            return NULL;
        }
		label->setAnchorPoint(ccp(0.5, 0.5));
        CCRenderTexture* rt = CCRenderTexture::create(label->getContentSize().width + RealSize*2, label->getContentSize().height + RealSize*2);
		rt->setAnchorPoint(ccp(0.0,0.0));
		rt->setPosition(0,0);
        if(rt->getSprite() && rt->getSprite()->getTexture())
        {
            rt->getSprite()->getTexture()->setAntiAliasTexParameters();
			rt->getSprite()->setOpacityModifyRGB(true);
        }
		else
		{
			CCLog("UILabelTTF null texture");
		}

		CCPoint originalPos = label->getPosition();
		ccColor3B originalColor = label->getColor();
		bool originalVisibility = label->isVisible();
		label->setColor(cor);
		label->setVisible(true);
		ccBlendFunc originalBlend = label->getBlendFunc();
		ccBlendFunc tBlendFunc = {GL_SRC_ALPHA, GL_ONE };
		label->setBlendFunc(tBlendFunc);

		rt->clear(0, 0, 0, 0);
		CCPoint center = ccp(label->getContentSize().width/2 ,label->getContentSize().height /2 );
		rt->begin();
		label->setPosition(ccp(center.x, center.y - RealSize));
		label->visit();
		label->setPosition(ccp(center.x + 2*RealSize, center.y - 2*RealSize));
		label->visit();
		label->setPosition(ccp(center.x + RealSize, center.y));
		label->visit();
		label->setPosition(ccp(center.x + 2*RealSize, center.y - RealSize));
		label->visit();
		label->setColor(originalColor);
		label->setPosition(ccp(center.x,center.y));
		label->visit();
		rt->end();

        label->setBlendFunc(originalBlend);
        label->setVisible(originalVisibility);
        label->setPosition(originalPos);

		// for test
		//char file[100];
		//sprintf(file,"../../temp/%s_creat.png",label->getString());
		//rt->saveToFile(file,kCCImageFormatPNG);
        return rt;
    }
开发者ID:niuzb,项目名称:hellopet,代码行数:56,代码来源:UILabelTTF.cpp

示例9: onPause

void GameScene::onPause(cocos2d::CCObject *pSender)
{
	pPauseMenu->setVisible(false);
	CCRenderTexture *renderTexture = CCRenderTexture::create(SCREEN_WIDTH, SCREEN_HEIGHT);
    renderTexture->begin();
    this->getParent()->visit();
    renderTexture->end();  //这里实际是通过CCRenderTexture保存当前界面(相当于截屏),然后传递给暂停界面,当成背景精灵
	pPauseMenu->setVisible(true);
    CCDirector::sharedDirector()->pushScene(PauseScene::scene(renderTexture,true));
}
开发者ID:renshengqiang,项目名称:MiniGame,代码行数:10,代码来源:GameScene.cpp

示例10: init

bool HelloWorld::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }

    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                      "CloseNormal.png",
                                      "CloseSelected.png",
                                      this,
                                      menu_selector(HelloWorld::menuCloseCallback));

    pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    CCSize size = CCDirector::sharedDirector()->getWinSize();

#if 0
    CCLayerColor *colorLayer = CCLayerColor::create(ccc4(0,80,80,255));
    addChild(colorLayer);

    CCSprite *spr_premulti = CCSprite::create("Ball.png");
    spr_premulti->setPosition(ccp(16,48));

    CCSprite *spr_nonpremulti = CCSprite::create("Ball.png");
    spr_nonpremulti->setPosition(ccp(16,16));


    CCRenderTexture *rend = CCRenderTexture::create(32, 64, kCCTexture2DPixelFormat_RGBA8888);

    if (rend == NULL)
        exit(0);

    rend->begin();
    spr_premulti->visit();
    spr_nonpremulti->visit();
    rend->end();

    addChild(spr_nonpremulti);
    addChild(spr_premulti);
    addChild(rend);
#endif

	scheduleUpdate();

    return true;
}
开发者ID:jinjianxin,项目名称:cocos2d-x,代码行数:55,代码来源:HelloWorldScene.cpp

示例11: addChild

RenderTextureIssue937::RenderTextureIssue937()
{
    /*
    *     1    2
    * A: A1   A2
    *
    * B: B1   B2
    *
    *  A1: premulti sprite
    *  A2: premulti render
    *
    *  B1: non-premulti sprite
    *  B2: non-premulti render
    */
    CCLayerColor *background = CCLayerColor::layerWithColor(ccc4(200,200,200,255));
    addChild(background);

    CCSprite *spr_premulti = CCSprite::spriteWithFile("Images/fire.png");
    spr_premulti->setPosition(ccp(16,48));

    CCSprite *spr_nonpremulti = CCSprite::spriteWithFile("Images/fire.png");
    spr_nonpremulti->setPosition(ccp(16,16));


    /* A2 & B2 setup */
    CCRenderTexture *rend = CCRenderTexture::renderTextureWithWidthAndHeight(32, 64);

	if (NULL == rend)
	{
		return;
	}

    // It's possible to modify the RenderTexture blending function by
    //		[[rend sprite] setBlendFunc:(ccBlendFunc) {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];

    rend->begin();
    spr_premulti->visit();
    spr_nonpremulti->visit();
    rend->end(); 

    CCSize s = CCDirector::sharedDirector()->getWinSize();

    /* A1: setup */
    spr_premulti->setPosition(ccp(s.width/2-16, s.height/2+16));
    /* B1: setup */
    spr_nonpremulti->setPosition(ccp(s.width/2-16, s.height/2-16));

    rend->setPosition(ccp(s.width/2+16, s.height/2));

    addChild(spr_nonpremulti);
    addChild(spr_premulti);
    addChild(rend);
}
开发者ID:BGCX261,项目名称:zombieswarmer-svn-to-git,代码行数:53,代码来源:RenderTextureTest.cpp

示例12: onEnter

void CCTransitionRadialCCW::onEnter()
{
	CCTransitionScene::onEnter();
	// create a transparent color layer
	// in which we are going to add our rendertextures
	CCSize size = CCDirector::sharedDirector()->getWinSize();

	// create the second render texture for outScene
	CCRenderTexture *outTexture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height);

	if (NULL == outTexture)
	{
		return;
	}
	
	outTexture->getSprite()->setAnchorPoint(ccp(0.5f,0.5f));
	outTexture->setPosition(ccp(size.width/2, size.height/2));
	outTexture->setAnchorPoint(ccp(0.5f,0.5f));

	// render outScene to its texturebuffer
	outTexture->clear(0,0,0,1);
	outTexture->begin();
	m_pOutScene->visit();
	outTexture->end();

	//	Since we've passed the outScene to the texture we don't need it.
	this->hideOutShowIn();

	//	We need the texture in RenderTexture.
	CCProgressTimer *outNode = CCProgressTimer::progressWithTexture(outTexture->getSprite()->getTexture());
	// but it's flipped upside down so we flip the sprite
	outNode->getSprite()->setFlipY(true);
	//	Return the radial type that we want to use
	outNode->setType(radialType());
	outNode->setPercentage(100.f);
	outNode->setPosition(ccp(size.width/2, size.height/2));
	outNode->setAnchorPoint(ccp(0.5f,0.5f));

	// create the blend action
	CCAction * layerAction = CCSequence::actions
	(
		CCProgressFromTo::actionWithDuration(m_fDuration, 100.0f, 0.0f),
		CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
		NULL
	);
	// run the blend action
	outNode->runAction(layerAction);

	// add the layer (which contains our two rendertextures) to the scene
	this->addChild(outNode, 2, kSceneRadial);
}
开发者ID:006,项目名称:ios_lab,代码行数:51,代码来源:CCTransitionRadial.cpp

示例13: createMaskSprite

    static CCSprite* createMaskSprite(CCLayerColor* base,
                                      const std::vector<CCRect>& cutoutList)
    {
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        
//        CCRenderTexture* rt = CCRenderTexture::create(winSize.width, winSize.height);
        
        // use a low-precision format
        CCRenderTexture* rt = CCRenderTexture::create(winSize.width,
                                                      winSize.height,
                                                      kTexture2DPixelFormat_RGBA8888);
        rt->setAnchorPoint(ccp(0, 0));
        rt->setPosition(ccp(0, 0));
        
        ccBlendFunc cutoutBlend = {GL_DST_ALPHA, GL_ZERO};
        
        // render to texture
        rt->begin();
        base->visit();

        CCSprite* s = CCSprite::create("ui/1x1_b.png");
        s->setAnchorPoint(ccp(0, 0));
        s->setOpacity(0);
        
        for(const CCRect& cutout : cutoutList)
        {
            s->setPosition(cutout.origin);
            s->setScaleX(cutout.size.width * contentScale());
            s->setScaleY(cutout.size.height * contentScale());

            s->setBlendFunc(cutoutBlend);
            s->visit();
        }
        rt->end();
        // render to texture done
        
        std::string randName = std::string("mask_image_") + boost::lexical_cast<std::string>(rand());

        CCImage* img = rt->newCCImage(false);
        img->autorelease();
        
        CCTexture2D* tex = CCTextureCache::sharedTextureCache()->addUIImage(img,
                                                                            randName.c_str());
        CCSprite *mask = CCSprite::createWithTexture(tex);
        mask->setFlipY(true);
        mask->setAnchorPoint(ccp(0, 0));
        mask->setPosition(ccp(0, 0));
        
        return mask;
    }
开发者ID:13609594236,项目名称:ph-open,代码行数:50,代码来源:TouchMaskLayer.cpp

示例14: postPhotoInUserAlbum

void FeedAPIScene::postPhotoInUserAlbum()
{
    CCRenderTexture *render = CCRenderTexture::create(AppDelegate::SCREEN_WIDTH, AppDelegate::SCREEN_HEIGHT);
    render->setPosition(ccp(AppDelegate::SCREEN_WIDTH / 2, AppDelegate::SCREEN_HEIGHT / 2));
    render->begin();
    CCDirector::sharedDirector()->getRunningScene()->visit();
    render->end();
    render->saveToFile("ScreenShot.jpg", kCCImageFormatJPEG);
    
    std::string filePathName = CCFileUtils::sharedFileUtils()->getWritablePath().append("ScreenShot.jpg");
    
    
    EziSocialObject::sharedObject()->postPhoto(filePathName.c_str(), "This is photo test message");
    //EziSocialObject::sharedObject()->postPhoto("ball.png", "This is photo test message");
}
开发者ID:ezibyte,项目名称:EziSocialDemo,代码行数:15,代码来源:FeedAPIScene.cpp

示例15: hit

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();
//	}
}
开发者ID:Raymond-Wong,项目名称:Orbitum,代码行数:17,代码来源:Player.cpp


注:本文中的CCRenderTexture::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。