Ejemplo n.º 1
0
Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, Ref *pOwner, const Size &parentSize)
{
    if (nullptr == pCCBFileName || strlen(pCCBFileName) == 0)
    {
        return nullptr;
    }

    std::string strCCBFileName(pCCBFileName);
    std::string strSuffix(".ccbi");
    // Add ccbi suffix
    if (!CCBReader::endsWith(strCCBFileName.c_str(), strSuffix.c_str()))
    {
        strCCBFileName += strSuffix;
    }

    auto fileUtils = FileUtils::getInstance();
    std::string strPath = fileUtils->fullPathForFilename(strCCBFileName);
    if (strPath.empty()) {
        return nullptr;
    }

    auto dataPtr = std::make_shared<Data>(fileUtils->getDataFromFile(strPath));
    if (dataPtr->isNull()) {
        return nullptr;
    }

    Node *ret =  this->readNodeGraphFromData(dataPtr, pOwner, parentSize);

    return ret;
}
Ejemplo n.º 2
0
bool LabelView::initWithString(const char *string, const char *fontName, float fontSize,
                                const CCSize& dimensions, CCTextAlignment hAlignment,
                               CCVerticalTextAlignment vAlignment) {
    int type = 1;
    std::string strCCBFileName(fontName);
    if (UiUtils::endsWith(strCCBFileName.c_str(), ".png")) {
        type = 3;
    } else if(UiUtils::endsWith(strCCBFileName.c_str(), ".fnt")){
        type = 2;
    } else {
        type = 1;
    }
    return initWithFontType(string, fontName, fontSize, type, dimensions, hAlignment, vAlignment);
}