HelloWorldScene.cpp中的函数中的代码如下:
CCScale9Sprite * scale9one = CCScale9Sprite::create("boxbg.png");
CCEditBox * myeditbox1=CCEditBox::create(CCSizeMake(200,40),scale9one);
myeditbox1->setInputMode(kEditBoxInputModeSingleLine);
myeditbox1->setPosition(ccp(mysize.width/2,mysize.height-100));
this->addChild(myeditbox1);
myeditbox1->setDelegate(this);
CCEditBox * myeditbox2=CCEditBox::create(CCSizeMake(200,40),scale9one);
myeditbox2->setInputMode(kEditBoxInputModeSingleLine);
myeditbox2->setInputFlag(kEditBoxInputFlagPassword);
myeditbox2->setPosition(ccp(mysize.width/2,mysize.height-200));
this->addChild(myeditbox2);
myeditbox2->setDelegate(this);
```
运行时报错。
Assert failed: child already added. It can't be added again
Assertion failed!
Expression: child->m_pParent == 0
如果删除myeditbox2的代码,或者重新建一个CCScale9Sprite 给myeditbox2用的话就没有问题。
CCScale9Sprite * scale9one2 = CCScale9Sprite::create("boxbg.png");
CCEditBox * myeditbox2=CCEditBox::create(CCSizeMake(200,40),scale9one2);
请问这是为什么?