I found a bug in CCSpawn where it fires the first two actions twice (once with time 0 and once with time 1) when created using an array of actions. I did not check to see if this is strictly with callFunc actions or other actions too, but it is at least an issue with those.
To test, I created a new Cocos2d-x project in Xcode, adding the following methods to the Helloworld.cpp file (and appropriate header additions):
void HelloWorld::logString(CCString *strVal) {
CCLog(strVal->getCString());
}
void HelloWorld::onEnter() {
CCLayer::onEnter();
CCLog("onEnter called");
CCArray* actions = CCArray::create();
// filler to keep spawn from double firing first two actions
for (int j = 0; j < 7; j++) {
CCString *strVal = CCString::createWithFormat("callFunc #%i", j);
CCCallFuncO* noAction = CCCallFuncO::create(this, callfuncO_selector(HelloWorld::logString), strVal);
actions->addObject(noAction);
}
CCSpawn *sAction = CCSpawn::create(actions);
this->runAction(sAction);
}
The console output was:
Cocos2d: onEnter called
Cocos2d: callFunc #0
Cocos2d: callFunc #1
Cocos2d: callFunc #2
Cocos2d: callFunc #3
Cocos2d: callFunc #4
Cocos2d: callFunc #5
Cocos2d: callFunc #6
Cocos2d: callFunc #0
Cocos2d: callFunc #1
Notice that callFunc #0/1 fire twice, but the rest do not. For use in my actual project, I am just prefilling the array with throw-away calls before doing the real actions, but this is a but that others might trip on so should be fixed.