Cocos2d - 最后一个场景未加载 - Child已添加。它无法再次添加

时间:2015-12-09 17:11:51

标签: ios cocos2d-iphone

在我的游戏中,最终场景前的场景,当我点击下一个带有消息的按钮时,它会崩溃;

"孩子已经添加了。它无法再次添加"

这是场景的代码段,我尝试调用的最终场景称为LastScene,但在加载场景之前它会崩溃。

bool LipsColorScene::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
    CCPoint location = CCDirector::sharedDirector()->convertToGL(pTouch->getLocationInView());

    if(_next->isVisible())
      {

    if(flagnext)
    {
    if(_next->boundingBox().containsPoint(location))
    {

        LipsColorScene::flagnext=false;
        CCLog("click next");
        _next->setVisible(false);
        _next->setPosition(ccp(1500, -500));
        lipstickscrollview->setVisible(false);
        imageForShowingMask->setVisible(false);
      //  this->setScale(1.0f);
        lipstickscrollview->setVisible(false);
        LipsColorScene::screenshot= this;
        CCDirector::sharedDirector()->getRunningScene()->removeChild(screenshot);
        lipstickscrollview->setVisible(false);
               imageForShowingMask->setVisible(false);
             //  this->setScale(1.0f);
               lipstickscrollview->setVisible(false);
      //  CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sounds/btn_clicksound.mp3");
        CCDirector::sharedDirector()->replaceScene(LastScene::scene());
    }
    }
      }
    if(imageForShowingMask->isVisible())
    {

        if(imageForShowingMask->boundingBox().containsPoint(location))
        {
            CCLOG("touch began");
            imageForShowingMask->setTag(1);
            setMaskingParamsForCream();
            //sprayparticle->resetSystem();
            spongeSelected = true;

            _eyes2->setVisible(true);
        }

    }

    if(_table->boundingBox().containsPoint(location)  && lipstickscrollview->isVisible())
    {
        if (lipstickscrollview->isVisible() && lipstickscrollview->isVisible() ) {
            for (int i = 0; i < lipstickArr->count(); i++) {
                CCSprite* tatoo = (CCSprite*)lipstickArr->objectAtIndex(i);

                if(tatoo->boundingBox().containsPoint(tatoo->getParent()->convertToNodeSpace(location)))
                {
                    //tatooscrollview->setVisible(false);
                    imageForShowingMask->setVisible(true);
                    LipStick(tatoo->getTag());

                }
            }
        }
    }


    return true;
}

1 个答案:

答案 0 :(得分:0)

if&#34; CCDirector :: sharedDirector() - &gt; replaceScene(LastScene :: scene());&#34;在你的代码中调用。在当前场景中无法解决任何原因。

检查你的&#34; LastScene&#34;。