当前位置: 首页>>代码示例>>C++>>正文


C++ GraphicLayer::createDropDownListFromSprite方法代码示例

本文整理汇总了C++中GraphicLayer::createDropDownListFromSprite方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicLayer::createDropDownListFromSprite方法的具体用法?C++ GraphicLayer::createDropDownListFromSprite怎么用?C++ GraphicLayer::createDropDownListFromSprite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicLayer的用法示例。


在下文中一共展示了GraphicLayer::createDropDownListFromSprite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadNodeToFenneX

void loadNodeToFenneX(Node* baseNode, Panel* parent)
{
    GraphicLayer* layer = GraphicLayer::sharedLayer();
    if(parent == NULL)
    {
        layer->useBaseLayer((Layer*)baseNode);
#if VERBOSE_LOAD_CCB
        CCLOG("replaced base layer by CCB node : position : %f, %f, scale : %f", baseNode->getPosition().x, baseNode->getPosition().y, baseNode->getScale());
#endif
    }
    
    //Use an index because InputLabel modify the array, so you need to rewind a bit at some point
    for(int i = 0; i < baseNode->getChildren().size(); i++)
    {
        Node* node = baseNode->getChildren().at(i);
#if VERBOSE_LOAD_CCB
        CCLOG("doing child %d from parent %s ...", i, parent != NULL ? parent->getName() != "" ? parent->getName().c_str() : "Panel" : "base layer");
#endif
        RawObject* result = NULL;
        if(isKindOfClass(node, Label))
        {
            Label* label = (Label*)node;
#if VERBOSE_LOAD_CCB
            CCLOG("label, font : %s", label->getSystemFontName().c_str());
#endif
            CCString* translationKey = isKindOfClass(label, CustomBaseNode) ? (CCString*)dynamic_cast<CustomBaseNode*>(label)->getParameters()->objectForKey("translationKey") : NULL;
            const std::string translated = Localization::getLocalizedString(translationKey != NULL ? translationKey->getCString() : label->getString());
            if(translationKey == NULL || translationKey->compare(translated.c_str()) != 0)
            { //Don't replace the string if it's the same, as it may only be a key, not a real label
                label->setString(translated);
            }
            result = layer->createLabelTTFromLabel(label, parent);
        }
        else if(isKindOfClass(node, CustomDropDownList))
        {
#if VERBOSE_LOAD_CCB
            CCLOG("DropDownList");
#endif
            Sprite* sprite = (Sprite*)node;
            result = layer->createDropDownListFromSprite(sprite, parent);
        }
        else if(isKindOfClass(node, Sprite))
        {
#if VERBOSE_LOAD_CCB
            CCLOG("image");
#endif
            Sprite* sprite = (Sprite*)node;
            result = layer->createImageFromSprite(sprite, parent);
        }
        else if(isKindOfClass(node, CustomInput))
        {
#if VERBOSE_LOAD_CCB
            CCLOG("input label");
#endif
            ui::Scale9Sprite* sprite = (ui::Scale9Sprite*)node;
            
            CCString* translationKey = isKindOfClass(sprite, CustomBaseNode) ? (CCString*)dynamic_cast<CustomBaseNode*>(sprite)->getParameters()->objectForKey("translationKey") : NULL;
            std::string placeHolder = isKindOfClass(sprite, CustomInput) ? ((CustomInput*) sprite)->getPlaceHolder()->getCString() : "";
            
            result = layer->createInputLabelFromScale9Sprite(sprite, parent);
            
            const std::string text = Localization::getLocalizedString(translationKey != NULL ? translationKey->getCString() : placeHolder.c_str());
            if(translationKey == NULL || translationKey->compare(text.c_str()) != 0)
            {
                ((InputLabel*) result)->setInitialText(text);
            }
            i--;
        }
        else if(isKindOfClass(node, ui::Scale9Sprite))
        {
#if VERBOSE_LOAD_CCB
            CCLOG("scale sprite");
#endif
            ui::Scale9Sprite* sprite = (ui::Scale9Sprite*)node;
            result = layer->createCustomObjectFromNode(sprite, parent);
        }
        else if(!isKindOfClass(node, ui::EditBox))
        {
#if VERBOSE_LOAD_CCB
            CCLOG("Edit Box");
#endif
            result = layer->createPanelFromNode(node, parent);
        }
#if VERBOSE_LOAD_CCB
        if(result != NULL)
        {
            CCLOG("Child %d loaded : position : %f, %f, scale : %f", i, result->getPosition().x, result->getPosition().y, result->getScale());
        }
        else
        {
            CCLOG("Problem loading child %d !", i);
        }
#endif
    }
}
开发者ID:makkajai,项目名称:FenneX,代码行数:95,代码来源:FenneXCCBLoader.cpp


注:本文中的GraphicLayer::createDropDownListFromSprite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。