不推荐使用CCMutableArray,如何更改代码

Ben*_*Ben 3 cocos2d-iphone cocos2d-x

我正在完成cocos2d-x SimpleGame项目,我被困在第5章,http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Chapter_5_-_How_to_Detect_the_Collisions.

我发现CCMutableArray不赞成使用CCArray.但是我如何修改以下内容,使其与CCArray一起使用(显然不支持模板)?

HelloWorldScene.h

cocos2d::CCMutableArray<cocos2d::CCSprite*> *_projectiles;
Run Code Online (Sandbox Code Playgroud)

HelloWorldScene.cpp

// in init()
// Initialize arrays
_projectiles = new CCMutableArray<CCSprite*>;

HelloWorld::~HelloWorld()
{
  if (_targets)
  {
    _projectiles->release();
    _projectiles = NULL;
  }
}

HelloWorld::HelloWorld()
:_projectiles(NULL)
{
}

void HelloWorld::update(float dt)
{
  CCArray *projectilesToDelete = new CCArray<CCSprite*>;
  CCMutableArray<CCSprite*>::CCMutableArrayIterator it, jt;

  for (it = _projectiles->begin(); it != _projectiles->end(); it++)
  {
     CCSprite *projectile = *it;
     // (...)
  }
  // (...)
}
Run Code Online (Sandbox Code Playgroud)

m.d*_*ing 6

我觉得是这样的

CCArray* array1 = CCArray::create();
Run Code Online (Sandbox Code Playgroud)

然后再使用它:

CCObject* arrayItem;
CCARRAY_FOREACH(array1, arrayItem){
    CCSprite* pItem = (CCSprite*)(arrayItem);
    //your code here
}
Run Code Online (Sandbox Code Playgroud)