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


C++ CCSpriteFrame类代码示例

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


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

示例1: CCArray

CCActionInterval* CCAnimate::reverse(void)
{
	CCArray *pOldArray = m_pAnimation->getFrames();
	CCArray *pNewArray = new CCArray(pOldArray->count());
   
	if (pOldArray->count() > 0)
	{
		CCSpriteFrame *pElement;
		//CCArray::CCMutableArrayRevIterator iter;
		//for (iter = pOldArray->rbegin(); iter != pOldArray->rend(); iter++)
		//{
		//	pElement = *iter;
		//	if (! pElement)
		//	{
		//		break;
		//	}

		//	pNewArray->addObject((CCSpriteFrame*)(pElement->copy()->autorelease()));
		//}
		CCObject* pObj = NULL;
		CCARRAY_FOREACH(pOldArray, pObj)
		{
			pElement = (CCSpriteFrame *)pObj;
			if (! pElement)
			{
				break;
			}

			pNewArray->addObject((CCSpriteFrame*)(pElement->copy()->autorelease()));
		}
开发者ID:GhostSoar,项目名称:Cocos2dWindows,代码行数:30,代码来源:CCActionInterval.cpp

示例2: getSpriteFrame

void HFHeadImgNode::onMyHeadImgLoaded(CCObject* object)
{
    // 本地上传的头像
    CCString* image = dynamic_cast<CCString*>(object);
    if (image == NULL) {
        return;
    }
    
    CCSpriteFrame* pFrame = getSpriteFrame(image->getCString());
    if (pFrame == NULL)
    {
        int removeState = remove(image->getCString());
        if (removeState==0 && m_retry<6)//重试5次
        {
            autoDefaultEnable tmp;
            m_retry++;
            HFUrlImageCache::shared()->loadImageAsync(m_headImgUrl, CCCallFuncO::create(this, callfuncO_selector(HFHeadImgNode::onMyheadImgBack), NULL));
        }
        return;
    }
    m_retry = 0;
    CCSize ccsz = pFrame->getOriginalSizeInPixels();
    m_myPortrait->setDisplayFrame(pFrame);
    m_myPortrait->setScale(m_scale * (90.0f/ccsz.width));
    m_headImgUrl.clear();
}
开发者ID:ourgames,项目名称:dc208,代码行数:26,代码来源:HFHeadImgNode.cpp

示例3: poffset

Skeleton2D_BoneDisplay* Skeleton2D_BoneDisplay::createWithSpriteFrameName(const char *pszSpriteFrameName,float anchorX,float anchorY)
{
	CCSpriteFrame *pSpriteFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(pszSpriteFrameName);

#if COCOS2D_DEBUG > 0
	char msg[256] = {0};
	sprintf(msg, "Invalid spriteFrameName: %s", pszSpriteFrameName);
	CCAssert(pSpriteFrame != NULL, msg);
#endif

	Skeleton2D_BoneDisplay *pobSprite = new Skeleton2D_BoneDisplay();
	if (pSpriteFrame && pobSprite && pobSprite->initWithSpriteFrame(pSpriteFrame))
	{
		pobSprite->setFlipY(true);
		pobSprite->autorelease();
		CCPoint poffset(anchorX,anchorY);
		CCSize psize=pSpriteFrame->getOriginalSize();
		float _anchorPointX = poffset.x / psize.width;
		float _anchorPointY = (poffset.y) / psize.height;
		pobSprite->setAnchorPoint(ccp(_anchorPointX, _anchorPointY));
		return pobSprite;
	}
	CC_SAFE_DELETE(pobSprite);
	return NULL;
}
开发者ID:boyjimeking,项目名称:Demo,代码行数:25,代码来源:SkeletonCocos2D.cpp

示例4: reverse

CCActionInterval* CCAnimate::reverse(void)
{
	CCMutableArray<CCSpriteFrame*> *pOldArray = m_pAnimation->getFrames();
	CCMutableArray<CCSpriteFrame*> *pNewArray = new CCMutableArray<CCSpriteFrame*>(pOldArray->count());
   
	if (pOldArray->count() > 0)
	{
		CCSpriteFrame *pElement;
		CCMutableArray<CCSpriteFrame*>::CCMutableArrayRevIterator iter;
		for (iter = pOldArray->rbegin(); iter != pOldArray->rend(); iter++)
		{
			pElement = *iter;
			if (! pElement)
			{
				break;
			}

			pNewArray->addObject((CCSpriteFrame*)(pElement->copy()->autorelease()));
		}
	}

	CCAnimation *pNewAnim = CCAnimation::animationWithFrames(pNewArray, m_pAnimation->getDelay());

	pNewArray->release();

	return CCAnimate::actionWithDuration(m_fDuration, pNewAnim, m_bRestoreOriginalFrame);
}
开发者ID:Openxlive,项目名称:cocos2d-x-win8-tests-metro-style,代码行数:27,代码来源:CCActionInterval.cpp

示例5: CCSpriteFrame

	CCSpriteFrame * CCSpriteFrame::createWithTexture(CCTexture2D* pobTexture, const CCRect& rect)
	{
		CCSpriteFrame* pRet = new CCSpriteFrame();
		pRet->_externalPointer = GAF::GAFMarmaladeGFX::createSpriteFrame(pobTexture->getExternalPointer(), rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
		pRet->autorelease();
		return pRet;
	}
开发者ID:digitalassetgroup,项目名称:-BIBS-Game,代码行数:7,代码来源:GAFSpriteFrame.cpp

示例6: CCSpriteFrame

CCSpriteFrame* CCSpriteFrame::frameWithTexture(CCTexture2D* pobTexture, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize)
{
    CCSpriteFrame *pSpriteFrame = new CCSpriteFrame();;
	pSpriteFrame->initWithTexture(pobTexture, rect, rotated, offset, originalSize);
	pSpriteFrame->autorelease();

	return pSpriteFrame;
}
开发者ID:MySure,项目名称:Test,代码行数:8,代码来源:CCSpriteFrame.cpp

示例7: CCSpriteFrame

CCSpriteFrame* CCSpriteFrame::create(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize)
{
    CCSpriteFrame *pSpriteFrame = new CCSpriteFrame();;
    pSpriteFrame->initWithTextureFilename(filename, rect, rotated, offset, originalSize);
    CC_SAFE_AUTORELEASE(pSpriteFrame);

    return pSpriteFrame;
}
开发者ID:boruis,项目名称:cocos2dx-classical,代码行数:8,代码来源:CCSpriteFrame.cpp

示例8: CCSpriteFrame

CCObject* CCSpriteFrame::copyWithZone(CCZone *pZone)
{
	CCSpriteFrame *pCopy = new CCSpriteFrame();
	
	pCopy->initWithTexture(m_pobTexture, m_obRectInPixels, m_bRotated, m_obOffsetInPixels, m_obOriginalSizeInPixels);
	
	return pCopy;
}
开发者ID:flyingpacer,项目名称:cocos2d-x-samples,代码行数:8,代码来源:CCSpriteFrame.cpp

示例9: CCSpriteFrame

CCSpriteFrame* CCSpriteFrame::create(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize)
{
    CCSpriteFrame *pSpriteFrame = new CCSpriteFrame();;
    pSpriteFrame->initWithTexture(pobTexture, rect, rotated, offset, originalSize);
    pSpriteFrame->autorelease();

    return pSpriteFrame;
}
开发者ID:boyjimeking,项目名称:LuckyCat,代码行数:8,代码来源:CCSpriteFrame.cpp

示例10: CC_UNUSED_PARAM

CCObject* CCSpriteFrame::copyWithZone(CCZone *pZone)
{
    CC_UNUSED_PARAM(pZone);
    CCSpriteFrame *pCopy = new CCSpriteFrame();
    CC_SAFE_AUTORELEASE(pCopy);
    pCopy->initWithTextureFilename(m_strTextureFilename.c_str(), m_obRectInPixels, m_bRotated, m_obOffsetInPixels, m_obOriginalSizeInPixels);
    pCopy->setTexture(m_pobTexture);
    return pCopy;
}
开发者ID:boruis,项目名称:cocos2dx-classical,代码行数:9,代码来源:CCSpriteFrame.cpp

示例11: CC_UNUSED_PARAM

CCObject* CCSpriteFrame::copyWithZone(CCZone *pZone)
{
    CC_UNUSED_PARAM(pZone);
	CCSpriteFrame *pCopy = new CCSpriteFrame();
	
	pCopy->initWithTexture(m_pobTexture, m_obRect, m_bRotated, m_obOffset, m_obOriginalSize);
	
	return pCopy;
}
开发者ID:noriter,项目名称:nit,代码行数:9,代码来源:CCSpriteFrame.cpp

示例12: CCSpriteFrame

NS_CC_BEGIN

// implementation of CCSpriteFrame

CCSpriteFrame* CCSpriteFrame::create(const char* filename, const CCRect& rect)
{
    CCSpriteFrame *pSpriteFrame = new CCSpriteFrame();;
    pSpriteFrame->initWithTextureFilename(filename, rect);
    pSpriteFrame->autorelease();

    return pSpriteFrame;
}
开发者ID:deepakjollybeeapps,项目名称:GeoSociety,代码行数:12,代码来源:CCSpriteFrame.cpp

示例13:

CCNode *APSSprite::createNode() {
    CCNode *node = APSGraphic::createNode();
    APSImageHolder *ih = this->getImageHolder();
    CCSize contentSize;
    CCSize targetSize = APSPlatform::sharedPlatform()->convertSizeToPixels(this->getSize());
    
    if (ih) {
        this->m_spriteNode = new CCSprite;
        if (this->getIsAnimatable()) {
            // Create animation sprite
            APSSpriteSheetHolder *sh = (APSSpriteSheetHolder *)ih;
            CCSpriteFrame *spriteFrame = sh->getCCSpriteFrameAtIndex(((APSGraphicGroup *)this->getParent())->getDisplayedFrameIndex());
            
#if COCOS2D_VERSION >= 0x00020000
            CCSpriteBatchNode *spriteSheet = CCSpriteBatchNode::createWithTexture(ih->getTexture(), sh->getCount());
#else
            CCSpriteBatchNode *spriteSheet = CCSpriteBatchNode::batchNodeWithTexture(ih->getTexture(), sh->getCount());
#endif//APS_SKIP
            this->m_node->addChild(spriteSheet);
            
            this->m_spriteNode->initWithSpriteFrame(spriteFrame);
            spriteSheet->addChild(this->m_spriteNode);
            
            CCSize size = this->m_spriteNode->getContentSize();
            contentSize = APSPlatform::sharedPlatform()->convertSizeToPixels(size);
            
        } else {
            // Check if there is a sprite frame in sprite frame cache.
            CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(this->getImageHolder()->getRuntimeFilename().c_str());
            if (frame) {
                // Use the sprite frame
                this->m_spriteNode->initWithSpriteFrame(frame);
                contentSize = frame->getOriginalSizeInPixels();
                node->addChild(this->m_spriteNode);
            } else {
                // Normal sprite
                this->m_spriteNode->initWithTexture(ih->getTexture());
                contentSize = ih->getTexture()->getContentSizeInPixels();
                node->addChild(this->m_spriteNode);
            }
        }
        
        // scale the sprite to match the sizes of texture and sprite
        this->m_spriteNode->setScaleX(targetSize.width/contentSize.width);
        this->m_spriteNode->setScaleY(targetSize.height/contentSize.height);
    }

    return node;
}
开发者ID:BradB132,项目名称:Cocos2dXML,代码行数:49,代码来源:APSSprite.cpp

示例14: while

void CCSpriteFrameCache::removeUnusedSpriteFrames(void)
{
	m_pSpriteFrames->begin();
	std::string key = "";
	CCSpriteFrame *spriteFrame = NULL;
	while( (spriteFrame = m_pSpriteFrames->next(&key)) )
	{
		if( spriteFrame->retainCount() == 1 ) 
		{
			CCLOG("cocos2d: CCSpriteFrameCache: removing unused frame: %s", key.c_str());
			m_pSpriteFrames->removeObjectForKey(key);
		}
	}
	m_pSpriteFrames->end();
}
开发者ID:9miao,项目名称:cocos2dx-win8,代码行数:15,代码来源:CCSpriteFrameCache.cpp

示例15: setPosition

 // Starts playing a given animation (or nothing if this animation is already playing)
 void CocosSpriteActorView::playAnimation(const std::string &name)
 {        
     if (name != _currentAnimation)
     {
         SpriteActorView::playAnimation(name);
     
         if (_currentAnimation != "")
         {
             // Sprite wasn't created yet. Create and set parameters
             if (!_ccSprite)
             {
                 _ccSprite = CCSprite::spriteWithSpriteFrame(((CocosAnimation *)_animations[_currentAnimation].get())->getFirstFrame());    
                 if (_ccSprite)
                 {
                     setPosition(getPosition());
                     setAngle(getAngle());
                     setScale(getScale());
                     setZOrder(getZOrder());
                     setVisible(isVisible());
                     setAlpha(getAlpha());
                 }
             }
             
             // The sprite was created, change texture
             if (_ccSprite)
             {
                 bool isAnimation = _animations[_currentAnimation]->getFrameCount() > 1;
                 
                 CCSpriteFrame *frame = ((CocosAnimation *)_animations[_currentAnimation].get())->getFirstFrame();
                 _ccSprite->setTexture(frame->getTexture());
                 CCRect frameRect = frame->getRectInPixels();
                 if (isAnimation)
                 {
                     frameRect.origin = frame->getOffsetInPixels();
                 }
                 _ccSprite->setTextureRect(frameRect);
                 _ccSprite->setDisplayFrame(frame);
                 
                 // If this animation contains more than one frame, play the animation
                 if (isAnimation)
                 {
                     _ccSprite->runAction(((CocosAnimation *)_animations[_currentAnimation].get())->getAnimationAction());
                 }
             }
             
         }
     }
 }
开发者ID:Avnerus,项目名称:ichigo,代码行数:49,代码来源:CocosSpriteActorView.cpp


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