1.Fix when first frame have no key frame, the armature don't display.

2.Fix color change bug
This commit is contained in:
yinkaile 2013-06-15 10:16:32 +08:00
parent e7d5ac3211
commit 57ada1fb36
6 changed files with 42 additions and 4 deletions

View File

@ -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));
}
}

View File

@ -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);

View File

@ -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)
{
}

View File

@ -155,6 +155,7 @@ public:
*/
std::string displayName;
CCBaseData skinData;
};
@ -268,6 +269,7 @@ public:
std::string name;
CCDictionary boneDataDic;
CCArray boneList;
float dataVersion;
};

View File

@ -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);

View File

@ -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;