本文整理汇总了C++中CCSpriteBatchNode::setContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCSpriteBatchNode::setContentSize方法的具体用法?C++ CCSpriteBatchNode::setContentSize怎么用?C++ CCSpriteBatchNode::setContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCSpriteBatchNode
的用法示例。
在下文中一共展示了CCSpriteBatchNode::setContentSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MergeSmallASprite
//// merge small piece asprite to a big one
CCNode* UIPicture::MergeSmallASprite(CCSprite* sprite)
{
if (!sprite)
return NULL;
CCTexture2D* ptexture = RecursiveFindTexture(sprite);
if (ptexture == NULL)
return sprite;
if(sprite->getChildrenCount() == 0)
{
return sprite;
}
CCArray* secondTextureSprite = CCArray::create();
while (sprite->getChildrenCount() > 0)
{
CCTexture2D* ptexture = RecursiveFindTexture(sprite);
/// create new batch node which used to store a series of sprites
CCSpriteBatchNode * pNode = CCSpriteBatchNode::createWithTexture(ptexture);
CCSize size = sprite->getContentSize();
CCPoint pt = sprite->getPosition();
pNode->setContentSize(size);
pNode->setAnchorPoint(ccp(0.0, 0.0));
secondTextureSprite->removeAllObjects();
int i = 0;
while(sprite->getChildrenCount() > 0)
{
CCArray* children = sprite->getChildren();
CCSprite* s1 = (CCSprite*)(children->lastObject());
sprite->removeChild(s1, false);
if (s1->getTexture() == ptexture)
{
pNode->addChild(s1, i--);
}else
{
secondTextureSprite->addObject(s1);
}
}
/// copy second texture sprite to sprite
CCObject* pTemp;
CCARRAY_FOREACH(secondTextureSprite, pTemp)
{
CCSprite* pPst = (CCSprite*) pTemp;
sprite->addChild(pPst);
}
if (!m_pSpriteNode)
{
/// 第一次创建时,取第一个sprite位置为当前m_pSpriteNode的位置
m_pSpriteNode = CCNode::create();
m_pSpriteNode->setPosition(pt);
m_pSpriteNode->setContentSize(size);
m_pSpriteNode->setAnchorPoint(sprite->getAnchorPoint());
pNode->setPosition(CCPointZero);
}else
{
/// convert other sprite to local position
CCPoint ptOrgio = m_pSpriteNode->getPosition();
pt = ccpSub(pt , ptOrgio);
pNode->setPosition(pt);
}
m_pSpriteNode->addChild(pNode);
}