Ejemplo n.º 1
0
AnimationData *DataReaderHelper::decodeAnimation(TiXmlElement *_animationXML)
{
    const char*	_name = _animationXML->Attribute(A_NAME);
    
//    AnimationData *_aniData = (AnimationData*)m_pAnimationDatas->objectForKey(_name);
//    if (_aniData)
//    {
//        //CCLOG("AnimationData (%s) is already exit", _name);
//        return;
//    }
    
    AnimationData *_aniData =  AnimationData::create();
    
    ArmatureData *_armatureData = ArmatureDataManager::sharedArmatureDataManager()->getArmatureData(_name);
    
    _aniData->setName(_name);
    
    TiXmlElement* _movementXML = _animationXML->FirstChildElement(MOVEMENT);
    
    while( _movementXML )
    {
        MovementData *_movementData = decodeMovement(_movementXML, _armatureData);
        _aniData->addMovement(_movementData);
        
        _movementXML = _movementXML->NextSiblingElement(MOVEMENT);
        
    }
    
    return _aniData;
    
}
CCAnimationData *CCDataReaderHelper::decodeAnimation(cs::CSJsonDictionary &json)
{
    CCAnimationData *aniData = CCAnimationData::create();

    const char *name = json.getItemStringValue(A_NAME);
    if(name != NULL)
    {
        aniData->name = name;
    }

    int length = json.getArrayItemCount(MOVEMENT_DATA);

    for (int i = 0; i < length; i++)
    {
        cs::CSJsonDictionary *dic = json.getSubItemFromArray(MOVEMENT_DATA, i);
        aniData->addMovement(decodeMovement(*dic));

        delete dic;
    }

    return aniData;
}
CCAnimationData *CCDataReaderHelper::decodeAnimation(tinyxml2::XMLElement *animationXML)
{
    const char	*name = animationXML->Attribute(A_NAME);


    CCAnimationData *aniData =  CCAnimationData::create();

    CCArmatureData *armatureData = CCArmatureDataManager::sharedArmatureDataManager()->getArmatureData(name);

    aniData->name = name;

    tinyxml2::XMLElement *movementXML = animationXML->FirstChildElement(MOVEMENT);

    while( movementXML )
    {
        CCMovementData *movementData = decodeMovement(movementXML, armatureData);
        aniData->addMovement(movementData);

        movementXML = movementXML->NextSiblingElement(MOVEMENT);

    }

    return aniData;
}