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


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

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


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

示例1: 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

示例2: 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

示例3: ccp

CCSprite *Puzzle::spriteImageMask() {
	
    // 1: Create new CCRenderTexture
    CCRenderTexture *rt = CCRenderTexture::renderTextureWithWidthAndHeight(Puzzle::canvasSize.width, Puzzle::canvasSize.height);
	
    // 2: Call CCRenderTexture:begin
    rt->beginWithClear(0, 0, 0, 0);
	
    // 3: Draw into the texture
	CCPoint vertices[4];
	
	glColor4ub(255, 255, 255, 255);
	for (int i = 0; i < numtaken; i++) {
		vertices[0] = ccp(taken[i].x, taken[i].y);
		vertices[1] = ccp(taken[i].x, taken[i].y + dimY);
		vertices[2] = ccp(taken[i].x + dimX, taken[i].y + dimY);
		vertices[3] = ccp(taken[i].x + dimX, taken[i].y);
		
		ccDrawPoly(vertices, 4, true, true);
	}
	
    // 4: Call CCRenderTexture:end
    rt->end();
	
    // 5: Create a new Sprite from the texture
	CCSprite *ret = CCSprite::spriteWithTexture(rt->getSprite()->getTexture());
	ret->setFlipY(true);
    return ret;
}
开发者ID:themoonlitknight,项目名称:PuzzleGuess,代码行数:29,代码来源:Puzzle.cpp

示例4: createWithColor

CCSprite* CCSprite::createWithColor(ccColor4F bgColor, float textureWidth, float textureHeight)
{
    CCRenderTexture *rt = CCRenderTexture::create(textureWidth, textureHeight);
    rt->beginWithClear(bgColor.r, bgColor.g, bgColor.b, bgColor.a);
    rt->end();
    return CCSprite::createWithTexture(rt->getSprite()->getTexture());
}
开发者ID:SunnyMeng,项目名称:DirectFire-android,代码行数:7,代码来源:CCSprite.cpp

示例5: 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

示例6: 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

示例7: generateTexture

CCTexture2D* Sky::generateTexture()
{
    CCRenderTexture* pRenderTexture = CCRenderTexture::create(m_nTextureSize, m_nTextureSize);
    pRenderTexture->beginWithClear(0.55f, 0.80f, 0.86f, 1.0f);
    
    //gradient
    float alpha = 1.0f;
    ccColor4B color1 = {255, 255, 255, 0};
    ccColor4B color2 = {255, 255, 255, 255};
    CCLayerGradient* pLayerColor = CCLayerGradient::create(color1, color2);
    pLayerColor->setContentSize(CCSizeMake(m_nTextureSize, m_nTextureSize));
    pLayerColor->setPosition(ccp(0, 0));
    pLayerColor->visit();
    
    //noise
    CCSprite* pSprite = CCSprite::create("noise.png");
    pSprite->setPosition(ccp(m_nTextureSize / 2, m_nTextureSize / 2));
    pSprite->setBlendFunc((ccBlendFunc){GL_DST_COLOR, GL_ZERO});
    pSprite->setScale(m_nTextureSize / 512.0f);
    pSprite->visit();
    
    pRenderTexture->end();
    CCTexture2D* pTex = pRenderTexture->getSprite()->getTexture();
    ccTexParams params = {GL_NEAREST, GL_NEAREST, GL_REPEAT, GL_REPEAT};
    pTex->setTexParameters(&params);
    return pTex;

}
开发者ID:Ratel13,项目名称:TinyWingsX,代码行数:28,代码来源:Sky.cpp

示例8: createRenderTextureFromLabel

CCRenderTexture* createRenderTextureFromLabel(CCLabelTTF* label)
{
	CCRenderTexture* render = CCRenderTexture::create(label->getContentSize().width, label->getContentSize().height);
	render->setPosition(label->getPosition());
	ccBlendFunc newBlendFuc = { GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA };
	render->getSprite()->setBlendFunc( newBlendFuc );

	render->setZOrder(label->getZOrder() + 1);
	label->setVisible(false);
	label->getParent()->addChild(render);

	return render;
}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:13,代码来源:LFUtile.cpp

示例9: fillBanner

void ADAds::fillBanner(Banner* banner)
{
#if defined(_DEBUG) && CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
    CCRenderTexture* texture = CCRenderTexture::create(100, 100);
    texture->beginWithClear(0.5f, 0.5f, 0.5f, 1);

    texture->end();

    CCSprite* s = CCSprite::createWithTexture(texture->getSprite()->getTexture());

    s->setScaleX(banner->getContentSize().width/s->getContentSize().width);
    s->setScaleY(banner->getContentSize().height/s->getContentSize().width);
    banner->addChild(s);
    s->setAnchorPoint(ccp(0,0));
    s->setPosition(ccp(0,0));
#endif

    if(_home_banners.size())
    {
        //std::random_shuffle(_home_banners.begin(), _home_banners.end());
        CustomBanner* home_ads = getCustomBanner();

        CCMenuItem* item = CCMenuItem::create(
                               home_ads, menu_selector(CustomBanner::onClick));


        CCMenu* menu = CCMenu::create();
        menu->addChild(item);

        banner->addChild(menu, 0, HOME_ADS_NODE_TAG);
        menu->setAnchorPoint(ccp(0,0));

        menu->setPosition(ccp(0,0));

        CCNode* banner_content = home_ads->getBanner();
        CCSize content_size = banner_content->getContentSize();
        CCSize zone_size = banner->getContentSize();

        float scale = MIN(zone_size.width/content_size.width,
                          zone_size.height/content_size.height);
        banner_content->setScale(scale);
        banner_content->setAnchorPoint(ccp(0, 0));
        banner_content->setPosition(ccp(0,0));

        item->setContentSize(content_size*scale);
        item->setAnchorPoint(ccp(0.5f,0.5f));
        item->setPosition(zone_size*0.5f);
        item->addChild(banner_content);
    }
}
开发者ID:4Enjoy,项目名称:ADLib,代码行数:50,代码来源:ADAds.cpp

示例10: spriteWithColor

CCSprite* EXDynamicTimeLayer::spriteWithColor(float alpha)
{
    CCRenderTexture* rt = CCRenderTexture::create(mBackgroundArea.width, mBackgroundArea.height, kCCTexture2DPixelFormat_RGBA8888);
    ccColor4F fColor = {0.0f,0.0f,0.0f,alpha};
    
    if (rt)
    {
        rt->beginWithClear(fColor.r, fColor.g, fColor.b, fColor.a);
        rt->end();
        
        return CCSprite::createWithTexture(rt->getSprite()->getTexture());
    }
    
    return NULL;
}
开发者ID:grefZhou,项目名称:cocos2dx-extensions-master,代码行数:15,代码来源:EXDynamicTimeLayer.cpp

示例11: spriteWithColor

//This is the old function
cocos2d::CCSprite* HelloWorld::spriteWithColor(cocos2d::ccColor4F bgColor, float textureWidth, float textureHeight)
{
    // 1: Create new CCRenderTexture
    CCRenderTexture *rt = CCRenderTexture::create(textureWidth, textureHeight);
    
    // 2: Call CCRenderTexture:begin
    rt->beginWithClear(bgColor.r, bgColor.g, bgColor.b, bgColor.a);
    
    this->setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionColor));
    
    CC_NODE_DRAW_SETUP();
    
    // 3: Draw into the texture
    float gradientAlpha = 0.7f;
    CCPoint vertices[4];
    ccColor4F colors[4];
    int nVertices = 0;
    
    vertices[nVertices] = ccp(0, 0);
    colors[nVertices++] = (ccColor4F){0, 0, 0, 0 };
    vertices[nVertices] = ccp(textureWidth, 0);
    colors[nVertices++] = (ccColor4F){0, 0, 0, 0};
    vertices[nVertices] = ccp(0, textureHeight);
    colors[nVertices++] = (ccColor4F){0, 0, 0, gradientAlpha};
    vertices[nVertices] = ccp(textureWidth, textureHeight);
    colors[nVertices++] = (ccColor4F){0, 0, 0, gradientAlpha};
    
    ccGLEnableVertexAttribs(kCCVertexAttribFlag_Position  | kCCVertexAttribFlag_Color);
    
    glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
    glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, colors);
    glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)nVertices);
    
    CCSprite *noise = CCSprite::create("Noise.png");
    ccBlendFunc bf = {GL_DST_COLOR, GL_ZERO};
    noise->setBlendFunc(bf);
    noise->setPosition(ccp(textureWidth/2, textureHeight/2));
    noise->visit();
    
    // 4: Call CCRenderTexture:end
    rt->end();
    
    // 5: Create a new Sprite from the texture
    return CCSprite::createWithTexture(rt->getSprite()->getTexture());    
}
开发者ID:JoeHu,项目名称:Cocos2d-x-1,代码行数:47,代码来源:HelloWorldScene.cpp

示例12: generateBackground

void GameLayer::generateBackground() {
    int textureSize = 512;
	ccColor4F c = ccc4f(140.0f/255.0f,205.0f/255.0f,221.0f/255.0f, 255.0f);
    CCRenderTexture * rt = CCRenderTexture::create(textureSize, textureSize);
    rt->beginWithClear(c.r, c.g, c.b, c.a);
    rt->end();
    
    setBackground(rt->getSprite());
    background->removeFromParentAndCleanup(true);
    
    background->setPosition(ccp(screenW/2,screenH/2));
    ccTexParams tp = {GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
    background->getTexture()->setTexParameters(&tp);
    
    addChild(background);
    return;
}
开发者ID:EricWang1992,项目名称:cocos2dx,代码行数:17,代码来源:GameLayer.cpp

示例13: getImage

CAImage* CAProgress::getImage(CAImage* image)
{
    CCRect rect;
    rect.origin = ccpSub(ccpMult(image->getContentSize(), 0.5f), CCPoint(0.5f, 0.5f));
    rect.size = CCSize(1, 1);
    
	CAScale9ImageView *scale9Image = CAScale9ImageView::createWithImage(rect, image);
    scale9Image->setAnchorPoint(CCPointZero);
	scale9Image->setPreferredSize(this->getBounds().size);
    this->addSubview(scale9Image);
    
	CCRenderTexture* render = CCRenderTexture::create(this->getBounds().size.width, this->getBounds().size.height, kCAImagePixelFormat_RGBA8888);
	render->beginWithClear(0, 0, 0, 0);
    scale9Image->visit();
	render->end();
    scale9Image->removeFromSuperview();
	return render->getSprite()->getImage();
}
开发者ID:tangyijie,项目名称:CrossApp,代码行数:18,代码来源:CAProgress.cpp

示例14: getImage

CAImage* CASwitch::getImage(CAImage* image, CCSize size)
{
	CAScale9ImageView *scale9Image = CAScale9ImageView::createWithImage(image);
    CCRect insetRect;
    insetRect.origin = scale9Image->getBounds().size / 2;
    insetRect.origin = ccpSub(insetRect.origin, CCPoint(1, 1));
    insetRect.size = CCPoint(2, 2);
    scale9Image->setCapInsets(insetRect);
    scale9Image->setAnchorPoint(CCPointZero);
	scale9Image->setFrame(CCRect(0, 0, size.width, size.height));
    this->addSubview(scale9Image);
    
	CCRenderTexture* render = CCRenderTexture::create(size.width, size.height, kCAImagePixelFormat_RGBA8888);
	render->beginWithClear(0, 0, 0, 0);
    scale9Image->visit();
	render->end();
    scale9Image->removeFromSuperview();
	return render->getSprite()->getImage();
}
开发者ID:anarki1234,项目名称:9miao,代码行数:19,代码来源:CASwitch.cpp

示例15: getImage

CAImage* CAProgress::getImage(CAImage* image)
{
	CCScale9Sprite *scale9Image = CCScale9Sprite::createWithImage(image);
    CCRect rect;
    rect.origin = scale9Image->getFrame().size/2;
    rect.origin = ccpSub(rect.origin, CCPoint(0.5f, 0.5f));
    rect.size = CCSize(1, 1);
    scale9Image->setCapInsets(rect);
	scale9Image->setPreferredSize(this->getBounds().size);
    scale9Image->setAnchorPoint(CCPointZero);
    this->addSubview(scale9Image);
    
	CCRenderTexture* render = CCRenderTexture::create(this->getBounds().size.width, this->getBounds().size.height, kCCTexture2DPixelFormat_RGBA8888);
	render->beginWithClear(0, 0, 0, 0);
    scale9Image->visit();
	render->end();
    scale9Image->removeFromSuperview();
	return render->getSprite()->getImage();
}
开发者ID:Jimlan,项目名称:CrossApp,代码行数:19,代码来源:CAProgress.cpp


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