本文整理汇总了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()));
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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());
}
}
}
}
}