Ejemplo n.º 1
0
void GameLayer::initAnswerLayer(std::vector<std::string> &StrVector)
{
    CCArray *answerChildren = _answerLayer->getChildren();
    
    _canAnsImageSize = static_cast<UIButton *>(answerChildren->objectAtIndex(0))->getContentSize();
    
    CCObject *obj_butt;
    
    int countPerRow = 8;
    int row = 0,col = 0;
    int currCount = 0;
    
    CCARRAY_FOREACH(answerChildren, obj_butt)
    {
        row = currCount / countPerRow;
        col = currCount % countPerRow;
        
        UIButton *anButt = (UIButton *)(obj_butt);
        anButt->setTouchEnable(true);
        anButt->addTouchEventListener(this,toucheventselector(GameLayer::answerButt));
        
        CCPoint buttPoint = CCPointMake(CG_FISTANBUTT_POINT.x + (CG_ANSWER_BUTT_SPACE_SIZE.width)* col, CG_FISTANBUTT_POINT.y + (CG_ANSWER_BUTT_SPACE_SIZE.height) * row);
        
        anButt->setPosition(buttPoint);
        
        std::string butt_titlt_str = StrVector.at(currCount);
        
        if (!CGHelper::isChineseChar(butt_titlt_str.c_str())) {
            anButt->setTitleFontSize(20);
        }
        
        anButt->setText(butt_titlt_str.c_str());
        currCount++;
    }