diff --git a/extensions/CCArmature/CCArmature.cpp b/extensions/CCArmature/CCArmature.cpp index 133635f9ea..76055e7c3a 100644 --- a/extensions/CCArmature/CCArmature.cpp +++ b/extensions/CCArmature/CCArmature.cpp @@ -407,7 +407,10 @@ void CCArmature::updateOffsetPoint() CCRect rect = boundingBox(); setContentSize(rect.size); m_pOffsetPoint = ccp(-rect.origin.x, -rect.origin.y); - setAnchorPoint(ccp(m_pOffsetPoint.x / rect.size.width, m_pOffsetPoint.y / rect.size.height)); + if (rect.size.width != 0 && rect.size.height!= 0) + { + setAnchorPoint(ccp(m_pOffsetPoint.x / rect.size.width, m_pOffsetPoint.y / rect.size.height)); + } } diff --git a/extensions/CCArmature/CCArmature.h b/extensions/CCArmature/CCArmature.h index 1d661a21fb..997e1e63ed 100644 --- a/extensions/CCArmature/CCArmature.h +++ b/extensions/CCArmature/CCArmature.h @@ -133,7 +133,7 @@ protected: CC_SYNTHESIZE_RETAIN(CCArmatureAnimation *, m_pAnimation, Animation); - CC_SYNTHESIZE(CCArmatureData *, m_pArmatureData, CCArmatureData); + CC_SYNTHESIZE(CCArmatureData *, m_pArmatureData, ArmatureData); CC_SYNTHESIZE(CCBatchNode*, m_pBatchNode, BatchNode); diff --git a/extensions/CCArmature/datas/CCDatas.cpp b/extensions/CCArmature/datas/CCDatas.cpp index ee06cced58..54a6a533b8 100644 --- a/extensions/CCArmature/datas/CCDatas.cpp +++ b/extensions/CCArmature/datas/CCDatas.cpp @@ -91,7 +91,11 @@ void CCBaseData::subtract(CCBaseData *from, CCBaseData *to) isUseColorInfo = true; } - + else + { + a = r = g = b = 0; + isUseColorInfo = false; + } if (skewX > M_PI) { @@ -228,6 +232,7 @@ CCDisplayData *CCBoneData::getDisplayData(int index) } CCArmatureData::CCArmatureData() + :dataVersion(0.1f) { } diff --git a/extensions/CCArmature/datas/CCDatas.h b/extensions/CCArmature/datas/CCDatas.h index 5310b8bfe2..9af512f676 100644 --- a/extensions/CCArmature/datas/CCDatas.h +++ b/extensions/CCArmature/datas/CCDatas.h @@ -155,6 +155,7 @@ public: */ std::string displayName; + CCBaseData skinData; }; @@ -268,6 +269,7 @@ public: std::string name; CCDictionary boneDataDic; CCArray boneList; + float dataVersion; }; diff --git a/extensions/CCArmature/display/CCDisplayFactory.cpp b/extensions/CCArmature/display/CCDisplayFactory.cpp index c3dfb38345..d8b48950a1 100644 --- a/extensions/CCArmature/display/CCDisplayFactory.cpp +++ b/extensions/CCArmature/display/CCDisplayFactory.cpp @@ -154,7 +154,18 @@ void CCDisplayFactory::createSpriteDisplay(CCBone *bone, CCDecorativeDisplay *de } skin->setBone(bone); - skin->setSkinData(*bone->getBoneData()); + CCArmature *armature = bone->getArmature(); + if (armature) + { + if (armature->getArmatureData()->dataVersion >= 0.15f) + { + skin->setSkinData(displayData->skinData); + } + else + { + skin->setSkinData(*bone->getBoneData()); + } + } decoDisplay->setDisplay(skin); diff --git a/extensions/CCArmature/utils/CCDataReaderHelper.cpp b/extensions/CCArmature/utils/CCDataReaderHelper.cpp index 7e451b65ef..5ec773408a 100644 --- a/extensions/CCArmature/utils/CCDataReaderHelper.cpp +++ b/extensions/CCArmature/utils/CCDataReaderHelper.cpp @@ -118,6 +118,7 @@ static const char *MOVEMENT_BONE_DATA = "mov_bone_data"; static const char *MOVEMENT_DATA = "mov_data"; static const char *ANIMATION_DATA = "animation_data"; static const char *DISPLAY_DATA = "display_data"; +static const char *SKIN_DATA = "skin_data"; static const char *BONE_DATA = "bone_data"; static const char *ARMATURE_DATA = "armature_data"; static const char *CONTOUR_DATA = "contour_data"; @@ -854,6 +855,8 @@ CCArmatureData *CCDataReaderHelper::decodeArmature(cs::CSJsonDictionary &json) armatureData->name = name; } + armatureData->dataVersion = json.getItemFloatValue("data_version", 0.1f); + int length = json.getArrayItemCount(BONE_DATA); for (int i = 0; i < length; i++) { @@ -913,6 +916,20 @@ CCDisplayData *CCDataReaderHelper::decodeBoneDisplay(cs::CSJsonDictionary &json) { ((CCSpriteDisplayData *)displayData)->displayName = name; } + + cs::CSJsonDictionary *dic = json.getSubItemFromArray(SKIN_DATA, 0); + if (dic != NULL) + { + CCSpriteDisplayData *sdd = (CCSpriteDisplayData *)displayData; + sdd->skinData.x = dic->getItemFloatValue(A_X, 0); + sdd->skinData.y = dic->getItemFloatValue(A_Y, 0); + sdd->skinData.scaleX = dic->getItemFloatValue(A_SCALE_X, 1); + sdd->skinData.scaleY = dic->getItemFloatValue(A_SCALE_Y, 1); + sdd->skinData.skewX = dic->getItemFloatValue(A_SKEW_X, 0); + sdd->skinData.skewY = dic->getItemFloatValue(A_SKEW_Y, 0); + delete dic; + } + } break;