cocos2d 的Action 如何在 scene 切换间自动播放和暂

当前一个 CCSprite 在执行  CCMoveTo 动作, 然后从当前 CCScene 切换到下一个 CCSence, 然后再切换回来后, 发现 这个 CCSprite 不动了。按理说 onEnter 后,就 resume 了所有的action了。 为什么会这样,怎样解决。
pushScene可以

replasceScne就是新的了
只是 retain 了一下吧, 而且切换回来后 CCSprite 还在切换前停留的位置, onEnter 里不是应该 resume 了吗
可以说得详细一点吗?
就是两个 CCScene 场景, scene1 和 scene2 吧, scene1 播放一个精灵的action(移动的), 播放过程中我用 replaceScene 切换到下一个场景 scene2. 再用 replaceScene 切换回 scene1 的时候精灵就卡在切换前的位置了。

这里 scene1 是自己保存了一个记数, 所以 replaceScene 的时候不会销毁再重新构造。
引用
终于明白了,原因在 sendCleanupToScene_ 这里, 当切换的时候检查这个变量:

        [runningScene_ onExit];

        // issue #709. the root node (scene) should receive the cleanup message too
        // otherwise it might be leaked.
        if( sendCleanupToScene_)
            [runningScene_ cleanup];

然后在 CCNode::cleanup  中停止了所有的action和 scheduleSelector 以及 子节点的所有。


- (void)cleanup
{
    // actions
    [self stopAllActions];
    [self unscheduleAllSelectors];
    
    // timers
    
    [children_ makeObjectsPerformSelector:@selector(cleanup)];
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值