Problem with Action Sequence inside Layer, which is added to the PlaysSceneLayer


Hi Guys,

I just started with cocos2d-x and ran into an problem using CCSequence, maybe somebody can give me a hint or solution,
’cause i have no idea what is happening there. My Game has a PlayScene with an PlaysSceneLayer.
There is another layer, which it’s added to the PlaySceneLayer, to show some animated Text.
The Action and Logic to animate these Texts I’d like to handle inside this Layer.
But that is not working properly. When i call “runAction” inside a added Layer, CCCallFunc is working, but NO CCSpawn or CCSequence.
Let me show you some Code:

In the Constructor i initialize the Layer for the text and call the method, that should run my Action.

  notificationLayer = new NotificationLayer();
  CCPoint *location = new CCPoint(100, 100);
  notificationLayer->addNote("test", location);

The “addNote” Method i declared in my Custom Layer:

void NotificationLayer::addNote(const char *note,CCPoint *position){
  CCLog("NotificationLayer::addNote(const char: %s)", note);
  CCLabelTTF *label = CCLabelTTF::labelWithString(note, CCSizeMake(200, 62), CCTextAlignmentCenter, Resources::FONT, 50);
    // CCCallFunc IS WORKING WELL!!!
  // action = CCCallFunc::actionWithTarget(this, callfunc_selector(NotificationLayer::callBack));

  // CCSpawn or CCSequence IS NOT WORKING!!!
  action = CCSequence::actions(CCDelayTime::actionWithDuration(1),
                               CCCallFunc::actionWithTarget(this, callfunc_selector(NotificationLayer::callback)),

Do you have an idea why CCSequence is not working in this case?

Thank you,


I haven’t invoked layer~~>runAction, normally sprite~~>runAction instead.
If you add NotificationLayer directly to CCScene, will CCSequence work on NotificationLayer?


You said CCCallFunc was working, and CCCallFunc is inside CCSequence,
so why did you say CCSequence not working?


Thank you for the very quick response. Now I’m adding my custom Layer directly to PlayScene with the same result.
CCFunc is working as a action of CCSequence, but CCSequence is working only with one Action. (The callback function does a simple CCLog())
Take a look:

action = CCSequence::actions(CCCallFuncN::actionWithTarget( this, callfuncN_selector(NotificationLayer::callback) ), 

 action = CCSequence::actions(CCCallFunc::actionWithTarget(this, callfunc_selector(NotificationLayer::callback)),
                               CCCallFunc::actionWithTarget(this, callfunc_selector(NotificationLayer::callback2)),

action = CCSpawn::actions(CCCallFunc::actionWithTarget(this, callfunc_selector(NotificationLayer::callback)),
                               CCCallFunc::actionWithTarget(this, callfunc_selector(NotificationLayer::callback2)),

Then i tried an action with duration. The following code snippet i put into the main PlaySceneLayer, where everything is working fine, and
into my Layer, where this code is not working. (I tested both ways: the layer as the only node of the PlayScene and as a node of the PlaySceneLayer)

CCLabelTTF *testLabel = CCLabelTTF::labelWithString("Test Label", CCSizeMake(200, 62), CCTextAlignmentCenter, "Arial", 50);
  CCAction *action = CCRotateBy::actionWithDuration( 2,  720);

Do you have any idea, maybe it has something to do with the time Step oder Update of my layer?


s. Thanks for your awsome work on cocos2d-x and that you spend your time on our questions


I think you can refer ActionSequence2 in ActionsTest.cpp.


I did a simple mistake and forgot to call the super CCLayer::onEnter(). That’s why i could not shedule the delayed Actions.


Martin Mulzer wrote:

I did a simple mistake and forgot to call the super CCLayer::onEnter(). That’s why i could not shedule the delayed Actions. Now everything is working fine.