Pause a layer


#1

Hi everyone,

Is there a built in way to pause a particular layer including all of its children and subchildren (recursively) with a single call?

I have tried pauseSchedulerAndActions() but that does not seem to affect the nodes children.

If there is not a built in way to do this can this be added, maybe as a flag to pauseSchedulerAndActions so that it now becomes:

pauseSchedulerAndActions ( bool includeChildren = false ); - This should maintain backwards compatibility too.

Regards,
James Mintram


#2

Yes there is not a pause function like you said.
A layer may contain a layer and a menu and a sprite.
CCSprite and CCLayer all inherit from CCNode, may be we should add pause function in CCNode.


#3

Feel free to use my recursive methods:

2Pause:

void GamePlayGuiLayer::RevursivelyPauseAllChildren( CCNode * node )
{
node~~>pauseSchedulerAndActions;
>
CCObject * obj;
CCARRAY_FOREACH, obj)
{
CCNode * n = obj;
RevursivelyPauseAllChildren;
}
}
2Resume:
void GamePlayGuiLayer::RevursivelyResumeAllChildren
{
node~~>resumeSchedulerAndActions();
>
CCObject * obj;
CCARRAY_FOREACH(node -> getChildren(), obj)
{
CCNode * n = (CCNode *)obj;
RevursivelyResumeAllChildren(n);
}
}


#4

Yeah it should be in cocos :slight_smile:


#5

hi Sergey Neskin,
thanks for your function…