Пример #1
0
    //----------------------
    // Status Label Group
    //----------------------
    TaskPtr StatusLabelGroup::setLabelWithAnim(CCLayer* layer,
                                               StatusLabelPtr label,
                                               std::string text,
                                               GemUtils::GemColor color,
                                               int zorder)
    {
        TaskSequencePtr seq = TaskSequence::make();
        
        /*
         ISSUES:
            StatusLabel::show will fail if setTextAndColor is not called.
            adding status label must be a delayed operation since 
            status labels could be removed in previous updates in the same frame.
         */

        
        // This must be delayed since label could be already scheduled
        // to be removed frame parent in the same frame.
        seq << TaskLambda::make([=]()
        {
            int i = findSlotForLabel(statusSlots, label);
            
            CCPoint p = evalPosition(i);
            label->setPosition(p);
            
            // not in slots
            if(statusSlots.size() == i)
            {
                statusSlots.push_back(label);
                if(layer)
                    layer->addChild(label->getRoot(), zorder);
            }
            // check if already in slots
            else if(!isInSlots(statusSlots, label))
            {
                statusSlots[i] = label;
                if(layer)
                    layer->addChild(label->getRoot(), zorder);
            }
            
            label->setTextAndColor(text, color);
        });
    
        seq << label->show();
        
        return seq;
    }
Пример #2
0
// Evaluate the current board position taking into account both material and
// position.
//
// @return an integer with a positive number for the White leading, negative
//         number for the Black leading and 0 for an equal situation. The
//         numbers is in centipawns, so it should be divided by 100 when
//         presented to the end user.
int eval()
{
    return evalMaterial() + evalPosition();
}