本文整理汇总了C++中CCTexture2D::retainCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTexture2D::retainCount方法的具体用法?C++ CCTexture2D::retainCount怎么用?C++ CCTexture2D::retainCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTexture2D
的用法示例。
在下文中一共展示了CCTexture2D::retainCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadedTexture
void UnloadableSpriteNode::loadedTexture(CCObject* obj)
{
CCTexture2D* aTex = (CCTexture2D*)obj;
if (aTex==NULL || aTex->retainCount()<=0) {
loading = false;
return;
}
aTex->setAntiAliasTexParameters();
//create sprite, position it and at to self
drawing = true;
this->_sprite = new CCSprite;
this->_sprite->initWithTexture(aTex);
this->_sprite->setAnchorPoint(ccp(0,0));
this->_sprite->setPosition(ccp(0,0));
// fill our activeRect fully with sprite (stretch if needed)
this->_sprite->setScaleX(this->_activeRect.size.width / this->_sprite->getContentSize().width);
this->_sprite->setScaleY(this->_activeRect.size.height / this->_sprite->getContentSize().height);
loading = false;
drawing = false;
}
示例2: removeUnusedTextures
void CCTextureCache::removeUnusedTextures()
{
std::vector<std::string> keys = m_pTextures->allKeys();
std::vector<std::string>::iterator it;
for (it = keys.begin(); it != keys.end(); it++)
{
CCTexture2D *value = m_pTextures->objectForKey(*it);
if (value->retainCount() == 1)
{
CCLOG("cocos2d: CCTextureCache: removing unused texture: %s", (*it).c_str());
m_pTextures->removeObjectForKey(*it);
}
}
}
示例3: CCListView_cellForRow
void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewProtrolData *data)
{
m_nCurrnetPage = data->nRow + 1;
CCListViewCell *cell = CCListViewCell::node();
cell->setOpacity(0);
cell->setContentSize(m_pList->getContentSize());
cell->setSelectionColor(ccc4(0, 0, 0, 0));
data->cell = cell;
CCSize listItemSize = CCSize(m_pList->getContentSize().width / NUM_PER_PAGE, m_pList->getContentSize().height);
CCSize size = CCSize(listItemSize.width * 0.9, listItemSize.height * 0.6);
sprintf(m_pszString, "%d/%d", m_nCurrnetPage, m_nTotalPage);
m_labelPage->setString(m_pszString);
float offX = 0, offY = 0, offsetX = 0, offsetY = 0;
CC_UNUSED_PARAM(offsetY);
int nCount = 0;
int nStart = (m_nCurrnetPage - 1) * NUM_PER_PAGE;
int nEnd = nStart + NUM_PER_PAGE;
CCDictElement* pElement = NULL;
CCDICT_FOREACH(m_pTextures, pElement)
{
if (nCount >= nStart && nCount < nEnd)
{
string key = pElement->getStrKey();
CCTexture2D* textrue = (CCTexture2D*)pElement->getObject();
//textrue = m_pTextures->objectForKey(*it);
if (textrue)
{
// reference count
sprintf(m_pszString, "[%d]", textrue->retainCount() - 2);
CCLabelTTF *labelCount = CCLabelTTF::labelWithString(m_pszString, "Arial", 16);
if (textrue->retainCount() - 2 > 0)
{
labelCount->setColor(ccc3(0, 255, 0));
}
else
{
labelCount->setColor(ccc3(255, 0, 0));
}
offX = offsetX + listItemSize.width * 0.5 - labelCount->getContentSize().width * 0.5;
offY = (listItemSize.height - size.height) * 0.5 - labelCount->getContentSize().height;
labelCount->setPosition(ccp(offX, offY));
labelCount->setAnchorPoint(ccp(0, 0));
cell->addChild(labelCount);
// texture size
sprintf(m_pszString, "%.0f*%.0f", textrue->getContentSize().width, textrue->getContentSize().height);
CCLabelTTF *labelSize = CCLabelTTF::labelWithString(m_pszString, "Arial", 16);
offX = offsetX + listItemSize.width * 0.5;
offY = (listItemSize.height - size.height) * 0.5 + size.height;
labelSize->setPosition(ccp(offX, offY));
labelSize->setAnchorPoint(ccp(0.5, 0));
cell->addChild(labelSize);
// texture name
int len = key.length();
int pos = 0;
pos = key.rfind('\\') + 1;
int pos2 = key.rfind('/') + 1;
pos = pos > pos2 ? pos : pos2;
string name = key.substr(pos, len - pos);
sprintf(m_pszString, "%s", name.c_str());
CCSize dimensions = CCSizeMake(listItemSize.width * 0.9, labelSize->getContentSize().height);
CCLabelTTF *labelName = CCLabelTTF::labelWithString(m_pszString, dimensions, CCTextAlignmentCenter, "Arial", 16);
offX = offsetX + listItemSize.width * 0.5;
offY = offY + labelName->getContentSize().height;
labelName->setPosition(ccp(offX, offY));
labelName->setAnchorPoint(ccp(0.5, 0));
cell->addChild(labelName);
CCSprite *sprite = CCSprite::spriteWithTexture(textrue);
sprite->setAnchorPoint(ccp(0, 0));
CCSize spriteSize = sprite->getContentSize();
float scale;
if (spriteSize.width < size.width && spriteSize.height < size.height)
{
scale = 1;
}
else if (spriteSize.width * size.height >= spriteSize.height * size.width)
{
scale = size.width / spriteSize.width;
}
else
{
scale = size.height / spriteSize.height;
}
sprite->setScale(scale);
spriteSize.width *= scale;
spriteSize.height *= scale;
offX = offsetX + (listItemSize.width - spriteSize.width) * 0.5;
offY = (listItemSize.height - spriteSize.height) * 0.5;
sprite->setPosition(ccp(offX, offY));
cell->addChild(sprite);
//.........这里部分代码省略.........