I found some code with deprecated CCMutableArrayIterator,but can’t to port to CCARRAY_FOREACH. Make some updates, but it is not enough
Code:
CCArray::CCMutableArrayIterator it;
if(__pEnemies && __pEnemies->count() > 0)
{
for(it = __pEnemies->begin(); it != __pEnemies->end(); it++)
{
Enemy* pEnemy = *it;
if(pEnemy)
{
CCRect enemyRect = pEnemy->getRect();
CCRect shipRect = __pShip->getRect();
bool collision = CCRect::CCRectIntersectsRect(shipRect, enemyRect);
if(((CCRect::getMinX(enemyRect) < 0) && (CCRect::getMaxX(enemyRect) < 0))
|| (collision))
{
// Enemy object is off the screen or colliding with the ship.
if(collision)
{
// Enemy object is colliding with the ship.
theEnd = true;
}
pObjectsToRemove->addObject(pEnemy);
}
}
}
}
if(pObjectsToRemove->count() > 0)
{
CCArray::CCMutableArrayIterator it;
for(it = pObjectsToRemove->begin(); it != pObjectsToRemove->end(); it++)
{
Enemy* pObjectToRemove = *it;
pObjectToRemove->destroy();
}
}
How to port this?
And one more. There’s some CCTouch events troubles:
CCPoint position = touch->locationInView(touch->view());
It return “Error: class”cocos2d::CCTouch" not include “view” member".
Didn’t find any references for that _view()_. What is it?