错误代码如下
1 2 3 4 5 |
local scrollLayer = CCScrollView:create(CCSizeMake(960,640)) local layer1 = CCLayer:create() scrollLayer:addChild(layer1) local layer2 = CCLayer:create() scrollLayer:setContainer(layer2) |
此时layer1被释放
经检查setContainer发现里面有一句this->removeAllChildrenWithCleanUp(true)
把layer1和layer2的添加顺序置换后问题消失