本文整理汇总了C++中CCMutableArray::release方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMutableArray::release方法的具体用法?C++ CCMutableArray::release怎么用?C++ CCMutableArray::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMutableArray
的用法示例。
在下文中一共展示了CCMutableArray::release方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: endElement
void endElement(void *ctx, const XML_Char *name)
{
std::string sName((char*)name);
if( sName == "dict" )
{
m_tDictStack.pop();
if ( !m_tDictStack.empty() )
{
m_pCurDict = (CCDictionary<std::string, CCObject*>*)(m_tDictStack.top());
}
}
else if (sName == "array")
{
CCAssert(m_bInArray, "The plist file is wrong!");
m_pCurDict->setObject(m_pArray, m_sCurKey);
m_pArray->release();
m_pArray = NULL;
m_bInArray = false;
}
else if (sName == "true")
{
CCString *str = new CCString("1");
if (m_bInArray)
{
m_pArray->addObject(str);
}
else
{
m_pCurDict->setObject(str, m_sCurKey);
}
str->release();
}
else if (sName == "false")
{
CCString *str = new CCString("0");
if (m_bInArray)
{
m_pArray->addObject(str);
}
else
{
m_pCurDict->setObject(str, m_sCurKey);
}
str->release();
}
m_tState = SAX_NONE;
}
示例3: startElement
void startElement(void *ctx, const char *name, const char **atts)
{
CC_UNUSED_PARAM(ctx);
CC_UNUSED_PARAM(atts);
std::string sName((char*)name);
if( sName == "dict" )
{
m_pCurDict = new CCDictionary<std::string, CCObject*>();
if(! m_pRootDict)
{
// Because it will call m_pCurDict->release() later, so retain here.
m_pRootDict = m_pCurDict;
m_pRootDict->retain();
}
m_tState = SAX_DICT;
CCSAXState preState = SAX_NONE;
if (! m_tStateStack.empty())
{
preState = m_tStateStack.top();
}
if (SAX_ARRAY == preState)
{
// add the dictionary into the array
m_pArray->addObject(m_pCurDict);
}
else if (SAX_DICT == preState)
{
// add the dictionary into the pre dictionary
CCAssert(! m_tDictStack.empty(), "The state is wrong!");
CCDictionary<std::string, CCObject*>* pPreDict = m_tDictStack.top();
pPreDict->setObject(m_pCurDict, m_sCurKey);
}
m_pCurDict->release();
// record the dict state
m_tStateStack.push(m_tState);
m_tDictStack.push(m_pCurDict);
}
else if(sName == "key")
{
m_tState = SAX_KEY;
}
else if(sName == "integer")
{
m_tState = SAX_INT;
}
else if(sName == "real")
{
m_tState = SAX_REAL;
}
else if(sName == "string")
{
m_tState = SAX_STRING;
}
else if (sName == "array")
{
m_tState = SAX_ARRAY;
m_pArray = new CCMutableArray<CCObject*>();
CCSAXState preState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top();
if (preState == SAX_DICT)
{
m_pCurDict->setObject(m_pArray, m_sCurKey);
}
else if (preState == SAX_ARRAY)
{
CCAssert(! m_tArrayStack.empty(), "The state is worng!");
CCMutableArray<CCObject*>* pPreArray = m_tArrayStack.top();
pPreArray->addObject(m_pArray);
}
m_pArray->release();
// record the array state
m_tStateStack.push(m_tState);
m_tArrayStack.push(m_pArray);
}
else
{
m_tState = SAX_NONE;
}
}
示例4: updateGame
void HelloWorld::updateGame(ccTime dt)
{
CCMutableArray<CCSprite*> *projectilesToDelete =
new CCMutableArray<CCSprite*>;
CCMutableArray<CCSprite*>::CCMutableArrayIterator it, jt;
for (it = _projectiles->begin(); it != _projectiles->end(); it++)
{
CCSprite *projectile =*it;
CCRect projectileRect = CCRectMake(
projectile->getPosition().x - (projectile->getContentSize().width/2),
projectile->getPosition().y - (projectile->getContentSize().height/2),
projectile->getContentSize().width,
projectile->getContentSize().height);
CCMutableArray<CCSprite*>*targetsToDelete =new CCMutableArray<CCSprite*>;
for (jt = _targets->begin(); jt != _targets->end(); jt++)
{
CCSprite *target =*jt;
CCRect targetRect = CCRectMake(
target->getPosition().x - (target->getContentSize().width/2),
target->getPosition().y - (target->getContentSize().height/2),
target->getContentSize().width,
target->getContentSize().height);
if (CCRect::CCRectIntersectsRect(projectileRect, targetRect))
{
targetsToDelete->addObject(target);
}
}
for (jt = targetsToDelete->begin(); jt != targetsToDelete->end(); jt++)
{
CCSprite *target =*jt;
_targets->removeObject(target);
this->removeChild(target, true);
_projectilesDestroyed++;
if (_projectilesDestroyed >= 5)
{
GameOverScene *gameOverScene = GameOverScene::node();
gameOverScene->getLayer()->getLabel()->setString("You Win!");
CCDirector::sharedDirector()->replaceScene(gameOverScene);
}
}
if (targetsToDelete->count() > 0)
{
projectilesToDelete->addObject(projectile);
}
targetsToDelete->release();
}
for (it = projectilesToDelete->begin(); it != projectilesToDelete->end(); it++)
{
CCSprite* projectile =*it;
_projectiles->removeObject(projectile);
this->removeChild(projectile, true);
}
projectilesToDelete->release();
}
示例5: update
void HelloWorld::update(float dt)
{
CCMutableArray<CCSprite*> *projectilesToDelete =
new CCMutableArray<CCSprite*>;
CCMutableArray<CCSprite*>::CCMutableArrayIterator it, jt, testt;
for (it = _projectiles->begin(); it != _projectiles->end(); it++)
{
CCSprite *projectile =*it;
CCRect projectileRect = CCRectMake(
projectile->getPosition().x - (projectile->getContentSize().width/2),
projectile->getPosition().y - (projectile->getContentSize().height/2),
projectile->getContentSize().width,
projectile->getContentSize().height);
CCMutableArray<CCSprite*>*targetsToDelete =new CCMutableArray<CCSprite*>;
//CCLOG("UPDATE2!!");
for (jt = _targets->begin(); jt != _targets->end(); jt++)
{
CCSprite *target =*jt;
CCRect targetRect = CCRectMake(
target->getPosition().x - (target->getContentSize().width/2),
target->getPosition().y - (target->getContentSize().height/2),
target->getContentSize().width,
target->getContentSize().height);
if (CCRect::CCRectIntersectsRect(projectileRect, targetRect))
{
targetsToDelete->addObject(target);
//CCLOG("HIT!!");
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("enemydeath.wav");
m_score->add_scroe(1);
m_score->update_logic(dt);
}
}
for (jt = targetsToDelete->begin(); jt != targetsToDelete->end(); jt++)
{
CCSprite *target =*jt;
_targets->removeObject(target);
this->removeChild(target, true);
_targetsKilled++;
//CCLOG("%d killed!", _targetsKilled);
if (_targetsKilled == GAMELENGTHVAL*10)
{
_targetsKilled = 0;
CCDirector::sharedDirector()->replaceScene(WinScene::scene());
}
}
if (targetsToDelete->count() >0)
{
projectilesToDelete->addObject(projectile);
}
targetsToDelete->release();
}
for (it = projectilesToDelete->begin(); it != projectilesToDelete->end(); it++)
{
CCSprite* projectile =*it;
_projectiles->removeObject(projectile);
this->removeChild(projectile, true);
}
projectilesToDelete->release();
}
示例6: testCollisions
void HelloWorld::testCollisions(ccTime dt)
{
CCMutableArray<CCSprite*> *projectilesToDelete = new CCMutableArray<CCSprite*>;
CCMutableArray<CCSprite *>::CCMutableArrayIterator it, jt;
// iterate through projectiles
for (it = _projectiles->begin(); it != _projectiles->end(); it++) {
CCSprite *projectile = *it;
CCRect projectileRect = CCRectMake(projectile->getPosition().x - (projectile->getContentSize().width/2),
projectile->getPosition().y - (projectile->getContentSize().height/2),
projectile->getContentSize().width,
projectile->getContentSize().height);
CCMutableArray<CCSprite*> *targetsToDelete = new CCMutableArray<CCSprite*>;
// iterate through enemies, see if any intersect with current projectile
for (jt = _enemies->begin(); jt != _enemies->end(); jt++)
{
CCSprite *target = *jt;
CCRect targetRect = CCRectMake(
target->getPosition().x - (target->getContentSize().width/2),
target->getPosition().y - (target->getContentSize().height/2),
target->getContentSize().width,
target->getContentSize().height);
if (CCRect::CCRectIntersectsRect(projectileRect, targetRect)) {
targetsToDelete->addObject(target);
}
}
// delete all hit enemies
for (jt = targetsToDelete->begin(); jt != targetsToDelete->end(); jt++)
{
_enemies->removeObject(*jt);
this->removeChild((*jt), true);
}
if (targetsToDelete->count() > 0)
{
projectilesToDelete->addObject(projectile);
}
targetsToDelete->release();
}
// remove all the projectiles that hit.
for (it = projectilesToDelete->begin(); it != projectilesToDelete->end(); it++) {
CCSprite *projectile = *it;
_projectiles->removeObject(projectile, true);
this->removeChild(projectile, true);
}
for (jt = _enemies->begin(); jt != _enemies->end(); jt++)
{
CCSprite *target = *jt;
CCRect targetRect = CCRectMake(
target->getPosition().x - (target->getContentSize().width/2),
target->getPosition().y - (target->getContentSize().height/2),
target->getContentSize().width,
target->getContentSize().height);
if (CCRect::CCRectContainsPoint(targetRect, _player->getPosition())) {
this->lose();
}
}
}
示例7: update
void HelloWorld::update(ccTime dt)
{
CCMutableArray<CCSprite*> *projectilesToDelete =
new CCMutableArray<CCSprite*>;
CCMutableArray<CCSprite*>::CCMutableArrayIterator it, jt;
for (it = _projectiles->begin(); it != _projectiles->end(); it++)
{
CCSprite *projectile =*it;
CCRect projectileRect = CCRectMake(
projectile->getPosition().x
- (projectile->getContentSize().width/2),
projectile->getPosition().y
- (projectile->getContentSize().height/2),
projectile->getContentSize().width,
projectile->getContentSize().height);
CCMutableArray<CCSprite*>*targetsToDelete
= new CCMutableArray<CCSprite*>;
for (jt = _targets->begin(); jt != _targets->end(); jt++)
{
CCSprite *target =*jt;
CCRect targetRect = CCRectMake(
target->getPosition().x - (target->getContentSize().width/2),
target->getPosition().y - (target->getContentSize().height/2),
target->getContentSize().width,
target->getContentSize().height);
if (CCRect::CCRectIntersectsRect(projectileRect, targetRect))
{
targetsToDelete->addObject(target);
}
}
for (jt = targetsToDelete->begin();
jt != targetsToDelete->end();
jt++)
{
CCSprite *target =*jt;
_targets->removeObject(target);
this->removeChild(target, true);
}
if (targetsToDelete->count() >0)
{
projectilesToDelete->addObject(projectile);
}
targetsToDelete->release();
}
for (it = projectilesToDelete->begin();
it != projectilesToDelete->end();
it++)
{
CCSprite* projectile =*it;
_projectiles->removeObject(projectile);
this->removeChild(projectile, true);
}
projectilesToDelete->release();
}