コード例 #1
0
ファイル: CustomInput.cpp プロジェクト: hossainiir/FenneX
bool CustomInput::onAssignCCBCustomProperty(CCObject* pTarget, const char* pMemberVariableName, const cocos2d::Value& pCCBValue)
{
    CustomInput* target = dynamic_cast<CustomInput*>(pTarget);
    if(pCCBValue.getType() == cocos2d::Value::Type::INTEGER && strcmp(pMemberVariableName, "maxChar") == 0)
    {
        target->setMaxChar(pCCBValue.asInt());
    }
    else if(pCCBValue.getType() == cocos2d::Value::Type::INTEGER && strcmp(pMemberVariableName, "fontSize") == 0)
    {
        target->setFontSize(pCCBValue.asInt());
    }
    else if(pCCBValue.getType() == cocos2d::Value::Type::STRING && strcmp(pMemberVariableName, "placeHolder") == 0)
    {
        target->setPlaceHolder(Screate(pCCBValue.asString()));
    }
    else if(pCCBValue.getType() == cocos2d::Value::Type::STRING && strcmp(pMemberVariableName, "fontName") == 0)
    {
        target->setFontName(Screate(pCCBValue.asString()));
    }
    else if(pCCBValue.getType() == cocos2d::Value::Type::BOOLEAN && strcmp(pMemberVariableName, "numbers") == 0)
    {
        target->setNumbersOnly(pCCBValue.asBool());
    }
    else
    {
        CustomBaseNode::onAssignCCBCustomProperty(pTarget, pMemberVariableName, pCCBValue);
    }
    return false;
}
コード例 #2
0
ファイル: JsonUtils.cpp プロジェクト: ArcticEmpire/Screw
void JsonValueConverter::value(const cocos2d::Value &v) {
    StackItem &current = _stack.back();
    if (current.value.getType() == cocos2d::Value::Type::MAP) {
        if (current.index %2 == 0) {
            CCASSERT(v.getType() == cocos2d::Value::Type::STRING, "Key must be a string");
            current.key = v.asString();
        } else {
            current.value.asValueMap()[current.key] = v;
        }
        current.index++;
    } else {
        current.value.asValueVector().push_back(v);
    }
}
コード例 #3
0
ファイル: Bird.cpp プロジェクト: psh880522/sh_game_framework
void CBird::actionCommand(const cocos2d::Value &value)
{
    switch (value.asInt()) {
        case CMD_MOVE:
        {
            changeState(ST_MOVE, CStateMachine::TR_OVERRIDE);
        }break;
        default:
            break;
    }
}
コード例 #4
0
void U8SDKNativeCallback::OnU8InitSuc(cocos2d::Node *sender, cocos2d::Value data)
{

	if (data.isNull() || data.getType() != cocos2d::Value::Type::MAP)
	{
		CCLOG("OnU8InitSuc Data Type Error:: curr data type is not map.");
		return;
	}

	cocos2d::ValueMap json = data.asValueMap();
	bool exit = json["isSupportExit"].asBool();
	bool accountCenter = json["isSupportAccountCenter"].asBool();
	bool logout = json["isSupportLogout"].asBool();

	U8SDKInterface::getInstance()->setSupports(exit, accountCenter, logout);

	if (this->gameCallback != nullptr)
	{
		this->gameCallback->OnInitSuc();
	}
}
コード例 #5
0
ファイル: JsonUtils.cpp プロジェクト: ArcticEmpire/Screw
string ValueJsonStringVisitor::visit(const cocos2d::Value &v) {
    switch (v.getType())
    {
        case cocos2d::Value::Type::NONE:
        case cocos2d::Value::Type::BYTE:
        case cocos2d::Value::Type::INTEGER:
        case cocos2d::Value::Type::FLOAT:
        case cocos2d::Value::Type::DOUBLE:
        case cocos2d::Value::Type::BOOLEAN:
            return v.asString();
            break;
        case cocos2d::Value::Type::STRING:
            return string("\"") + v.asString() + string("\"");
            break;
        case cocos2d::Value::Type::VECTOR:
            return visit(v.asValueVector());
            break;
        case cocos2d::Value::Type::MAP:
            return visitMap<ValueMap>(v.asValueMap());
            break;
        case cocos2d::Value::Type::INT_KEY_MAP:
            return visitMap<ValueMapIntKey>(v.asIntKeyMap());
            break;
        default:
            CCASSERT(false, "Invalid type!");
            break;
    }
}
コード例 #6
0
void U8SDKNativeCallback::OnU8LoginSuc(cocos2d::Node *sender, cocos2d::Value data)
{
	if (data.isNull() || data.getType() != cocos2d::Value::Type::MAP)
	{
		CCLOG("OnU8LoginSuc Data Type Error:: curr data type is not map.");
		return;
	}

	U8LoginResult* result = U8LoginResult::create();
	cocos2d::ValueMap json = data.asValueMap();
	result->isSuc = json["isSuc"].asBool();
	result->isSwitchAccount = json["isSwitchAccount"].asBool();
	result->userId = json["userID"].asString();
	result->sdkUserId = json["sdkUserID"].asString();
	result->username = json["username"].asString();
	result->sdkUsername = json["sdkUsername"].asString();
	result->token = json["token"].asString();

	if (this->gameCallback != nullptr)
	{
		this->gameCallback->OnLoginSuc(result);
	}
}
コード例 #7
0
ファイル: JsonUtils.cpp プロジェクト: ArcticEmpire/Screw
string JsonUtils::toJsonString(cocos2d::Value &v) {
    CCASSERT(v.getType() == cocos2d::Value::Type::INT_KEY_MAP || v.getType() == cocos2d::Value::Type::MAP ||
             v.getType() == cocos2d::Value::Type::VECTOR, "Only map and vector are valid");
    return ValueJsonStringVisitor::visit(v);
}
コード例 #8
0
void HelloWorld::listTags(cocos2d::Value value) {
    CCLOG("%s", value.getDescription().c_str());
}