刚开始接触这个东西,弄了好久都没有弄好,我自己太笨了,现在我将如何创建一个CCLayerMultiplex过程写出来,代码如下:
CCLayer *mainLayer = new MenuDemo; CCLayer *menu1 = new MenuDemoItem1; CCLayer *menu2 = new MenuDemoItem2; CCLayer *menu3 = new MenuDemoItem3; CCLayerMultiplex *Menu_multiplex = CCLayerMultiplex::create(mainLayer, menu1, menu2, menu3, NULL); addChild(Menu_multiplex, 0); mainLayer->release(); menu1->release(); menu2->release(); menu3->release(); CCDirector::sharedDirector()->replaceScene(this);
然后写回调函数了:
void MenuDemo::fontMenu1_callBack(CCObject *object) { ((CCLayerMultiplex*)(m_pParent))->switchTo(2); } void MenuDemo::fontMenu2_callBack(CCObject *object) { ((CCLayerMultiplex*)(m_pParent))->switchTo(3); } void MenuDemo::fontMenu3_callBack(CCObject *object) { ((CCLayerMultiplex*)(m_pParent))->switchTo(1); }
这样基本上就创建完成了!