I have a mobile game, utilizing cocos2d-x, that has a handler for touch events.What it does:Main function that gets the touch.Loop in module A. All sprites check if the touch coordinates are in the boundary of one of the sprite. If yes, call the function that associated with the action and break the loop.The same as 2 with module B.Same as 2,3, with module C and so on.In some some parts of the loop there are Boolean indicators that say:If boolInd1 is true, ignore touches from Module A.If boolInd2 is true, ignore touches from Module B.and so on...It's a very long and complex function, and I was wondering if I can rewrite this function with a better structure.void MainGame::onTouchesBegan(const std::vector<Touch*>& touches, Event  *event){    bool FontSignTouched = false;     for( auto& touch : touches)    {        auto location = touch->getLocation();         //once the next level button is triggered to show all other touchs are disabled         Vector<Node *> ScoreContainerChildren = pScoreContainer->getChildren();        for (auto iter = ScoreContainerChildren.begin(); iter != ScoreContainerChildren.end(); ++iter)         {            Node *childNode = *iter;             if(childNode->getTag() == buttons_tags::SOUND_BT)            {                Point thisTouchScoreContainer = pScoreContainer->convertTouchToNodeSpace(touch);                 Sprite* pSoundBT = static_cast<Sprite*>(*iter);                 if(pSoundBT->getBoundingBox().containsPoint(thisTouchScoreContainer))                {                    pScoreContainer->setSoundButtonSpriteFrame(true);                    break;                }            }            if(childNode->getTag() == buttons_tags::POINTS_CONTAINER_NODE)            {                Sprite* pCoinsBT = (Sprite*)childNode->getChildByTag(buttons_tags::COINS_IMG_BT);                Sprite* pCoinsCountFrameBT = (Sprite*)childNode->getChildByTag(buttons_tags::COINS_COUNT_FRAME);                Point thisTouchPointsContainerNode = childNode->convertTouchToNodeSpace(touch);                 if(pCoinsBT->getBoundingBox().containsPoint(thisTouchPointsContainerNode))                {                    setPopUpWindow();                    break;                }                if(pCoinsCountFrameBT->getBoundingBox().containsPoint(thisTouchPointsContainerNode))                {                    setPopUpWindow();                    break;                }                            }        }        Vector<Node *> FontSelectionContainerChildren = pFontSelectionContainer->getChildren();        for (auto iter = FontSelectionContainerChildren.begin(); iter != FontSelectionContainerChildren.end(); ++iter)         {            Node *childNode = *iter;             if(childNode->getTag() == sign_tags::LETTER_SIGH)            {                Point thisTouchPositionFontSelection = this->convertTouchToNodeSpace(touch);                 Sign* pSign = static_cast<Sign*>(*iter);                 if(pSign->getBoundingBox().containsPoint(thisTouchPositionFontSelection))                {                    Settings::getInstance()->getSoundManager().playEffect(FONT_TO_SOLUTION);                    pSolutionContainer->setFontSelectionToSulotionFont(pSign);                    FontSignTouched = true;                    break;                }            }        }        Vector<Node *> thisSelectionChildren = this->getChildren();         if(!FontSignTouched)        {            for (auto iter = thisSelectionChildren.begin(); iter != thisSelectionChildren.end(); ++iter)             {                Node *childNode = *iter;                 if(childNode->getTag() == sign_tags::LETTER_SIGH)                {                    Point thisTouchPositionFontSelection = this->convertTouchToNodeSpace(touch);                      Sign* pSign = static_cast<Sign*>(*iter);                     if(pSign->getBoundingBox().containsPoint(thisTouchPositionFontSelection))                    {                        Settings::getInstance()->getSoundManager().playEffect(SOLUTION_TO_FONT);                        pFontSelectionContainer->removeFromMainParantAndSetInSprite(pSign);                        break;                    }                }                if(childNode->getTag() == buttons_tags::NEXT_BT)                {                    Point thisTouchPositionFontSelection = this->convertTouchToNodeSpace(touch);                      Sign* pSign = static_cast<Sign*>(*iter);                     if(pSign->getBoundingBox().containsPoint(thisTouchPositionFontSelection))                    {                    }                }            }        }        else        {            FontSignTouched = false;        }    }} 
Messy handler for multiple touch events in a game
c++;event handling