Adding actions dynamically to CCSequence

Adding actions dynamically to CCSequence
0.0 0


To build a CCSequence dynamically I am adding actions to a CCArray then calling the create:

CCSequence *sq = CCSequence::create(actionList);

The sequence requires a NULL at the end but CCArrays do not allow you to add NULL, or even an object with a NULL value.

So how can I dynamically add actions to a sequence?



As far as i know, when using CCArray to create a CCSequence, you don’t need to add a NULL to the array.


You’re right. I was getting an error that I thought was related to the lack of NULL. I went ahead and found a work-around that I thought I would share, even though I am now back to using the array as it’s much nicer to work with.

CCFiniteTimeAction* makeSequence(CCArray * moves) {
    CCFiniteTimeAction *seq = NULL;
    CCObject* it = NULL;
    CCARRAY_FOREACH(moves, it) {
        CCFiniteTimeAction *action = dynamic_cast(it);
        if (!seq) {
            seq = action;
        } else {
            seq = CCSequence::create(seq,action,NULL);
    return seq;

Thanks for taking the time to reply.