LayerMultiplex 大坑

multi = LayerMultiplex::createWithArray(layers);

调用  multi->switchTo(n);   

里面会调用 this->removeChild(_layers.at(_enabledLayer), true);  把当前层remove,  可是当前layer,是被从multi的layerremove掉了,

但是它仍然在multi的Vector<Layer*>    _layers;里,    导致其所有儿子不能被释放,所有儿子都还附属在remove掉的那个层里。

所以必须在layer的onEnter函数 重写后 把上次onEnter加进来的儿子全部remove掉才不会内存泄露。



要记住 :  child->removeFromParentAndCleanup(true);  它做的是 setParent(NULL)+_children.rease(index)  , child的儿子孙子类的只有

做cleanup()动作,  要知道cleanup只是 停掉两个东西而已,(stopAllActions(),unscheduleAllSelectors()) 然后等待内存管理来自动释放。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值