1.Fix empty frame bug

2.Change Skin function interface name
This commit is contained in:
yinkaile 2013-07-02 10:32:32 +08:00
parent 5d94a5594c
commit 58550a834c
6 changed files with 34 additions and 32 deletions

View File

@ -460,7 +460,7 @@ void CCArmature::draw()
if (m_pAtlas->getCapacity() == m_pAtlas->getTotalQuads() && !m_pAtlas->resizeCapacity(m_pAtlas->getCapacity() * 2)) if (m_pAtlas->getCapacity() == m_pAtlas->getTotalQuads() && !m_pAtlas->resizeCapacity(m_pAtlas->getCapacity() * 2))
return; return;
skin->draw(); skin->updateTransform();
} }
else if(CCArmature *armature = dynamic_cast<CCArmature *>(node)) else if(CCArmature *armature = dynamic_cast<CCArmature *>(node))
{ {

View File

@ -83,6 +83,7 @@ bool CCTween::init(CCBone *bone)
m_pBone = bone; m_pBone = bone;
m_pTweenData = m_pBone->getTweenData(); m_pTweenData = m_pBone->getTweenData();
m_pTweenData->displayIndex = -1;
m_pAnimation = m_pBone->getArmature() != NULL ? m_pBone->getArmature()->getAnimation() : NULL; m_pAnimation = m_pBone->getArmature() != NULL ? m_pBone->getArmature()->getAnimation() : NULL;
@ -94,43 +95,42 @@ bool CCTween::init(CCBone *bone)
} }
void CCTween::play(CCMovementBoneData *_movementBoneData, int _durationTo, int _durationTween, int _loop, int _tweenEasing) void CCTween::play(CCMovementBoneData *movementBoneData, int durationTo, int durationTween, int loop, int tweenEasing)
{ {
CCProcessBase::play(NULL, _durationTo, _durationTween, _loop, _tweenEasing); CCProcessBase::play(NULL, durationTo, durationTween, loop, tweenEasing);
m_eLoopType = (AnimationType)_loop; m_eLoopType = (AnimationType)loop;
m_pCurrentKeyFrame = NULL; m_pCurrentKeyFrame = NULL;
m_bIsTweenKeyFrame = false;
m_iTotalDuration = 0; m_iTotalDuration = 0;
betweenDuration = 0; betweenDuration = 0;
m_iToIndex = 0; m_iToIndex = 0;
setMovementBoneData(_movementBoneData); bool difMovement = movementBoneData != m_pMovementBoneData;
setMovementBoneData(movementBoneData);
CCFrameData *nextKeyFrame = m_pMovementBoneData->getFrameData(0);
m_pTweenData->displayIndex = nextKeyFrame->displayIndex;
if (m_pMovementBoneData->frameList.count() == 1) if (m_pMovementBoneData->frameList.count() == 1)
{ {
m_eLoopType = SINGLE_FRAME; m_eLoopType = SINGLE_FRAME;
CCFrameData *_nextKeyFrame = m_pMovementBoneData->getFrameData(0); if(durationTo == 0)
if(_durationTo == 0)
{ {
setBetween(_nextKeyFrame, _nextKeyFrame); setBetween(nextKeyFrame, nextKeyFrame);
} }
else else
{ {
m_pTweenData->displayIndex = _nextKeyFrame->displayIndex; setBetween(m_pTweenData, nextKeyFrame);
setBetween(m_pTweenData, _nextKeyFrame);
} }
m_bIsTweenKeyFrame = true;
m_eFrameTweenEasing = Linear; m_eFrameTweenEasing = Linear;
m_iRawDuration = m_pMovementBoneData->duration; m_iRawDuration = m_pMovementBoneData->duration;
m_iFromIndex = m_iToIndex = 0; m_iFromIndex = m_iToIndex = 0;
} }
else if (m_pMovementBoneData->frameList.count() > 1) else if (m_pMovementBoneData->frameList.count() > 1)
{ {
if (_loop) if (loop)
{ {
m_eLoopType = ANIMATION_TO_LOOP_BACK; m_eLoopType = ANIMATION_TO_LOOP_BACK;
m_iRawDuration = m_pMovementBoneData->duration; m_iRawDuration = m_pMovementBoneData->duration;
@ -141,18 +141,22 @@ void CCTween::play(CCMovementBoneData *_movementBoneData, int _durationTo, int _
m_iRawDuration = m_pMovementBoneData->duration - 1; m_iRawDuration = m_pMovementBoneData->duration - 1;
} }
m_iDurationTween = _durationTween * m_pMovementBoneData->scale; m_iDurationTween = durationTween * m_pMovementBoneData->scale;
if (_loop && m_pMovementBoneData->delay != 0) if (loop && m_pMovementBoneData->delay != 0)
{ {
setBetween(m_pTweenData, tweenNodeTo(updateFrameData(1 - m_pMovementBoneData->delay), m_pBetween)); setBetween(m_pTweenData, tweenNodeTo(updateFrameData(1 - m_pMovementBoneData->delay), m_pBetween));
} }
else else
{ {
CCFrameData *_nextKeyFrame = m_pMovementBoneData->getFrameData(0); if (!difMovement)
setBetween(m_pTweenData, _nextKeyFrame); {
m_bIsTweenKeyFrame = true; setBetween(nextKeyFrame, nextKeyFrame);
}
else
{
setBetween(m_pTweenData, nextKeyFrame);
}
} }
} }
@ -272,18 +276,18 @@ void CCTween::setBetween(CCFrameData *from, CCFrameData *to)
{ {
do do
{ {
if(to->displayIndex < 0 && from->displayIndex > 0) if(from->displayIndex < 0 && to->displayIndex >= 0)
{
m_pFrom->copy(to);
m_pBetween->subtract(to, to);
break;
}
else if(to->displayIndex < 0 && from->displayIndex >= 0)
{ {
m_pFrom->copy(from); m_pFrom->copy(from);
m_pBetween->subtract(to, to); m_pBetween->subtract(to, to);
break; break;
} }
else if(from->displayIndex < 0 && to->displayIndex > 0)
{
m_pFrom->copy(to);
m_pBetween->subtract(to, to);
break;
}
m_pFrom->copy(from); m_pFrom->copy(from);
m_pBetween->subtract(from, to); m_pBetween->subtract(from, to);

View File

@ -130,8 +130,6 @@ protected:
CCTweenType m_eFrameTweenEasing; //! Dedermine which tween effect current frame use CCTweenType m_eFrameTweenEasing; //! Dedermine which tween effect current frame use
bool m_bIsTweenKeyFrame;
int betweenDuration; //! Current key frame will last betweenDuration frames int betweenDuration; //! Current key frame will last betweenDuration frames
int m_iTotalDuration; int m_iTotalDuration;

View File

@ -185,7 +185,7 @@ void CCDisplayFactory::createSpriteDisplay(CCBone *bone, CCDecorativeDisplay *de
void CCDisplayFactory::updateSpriteDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay, float dt, bool dirty) void CCDisplayFactory::updateSpriteDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay, float dt, bool dirty)
{ {
CCSkin *skin = (CCSkin *)decoDisplay->getDisplay(); CCSkin *skin = (CCSkin *)decoDisplay->getDisplay();
skin->updateTransform(); skin->updateArmatureTransform();
} }

View File

@ -79,12 +79,12 @@ const CCBaseData &CCSkin::getSkinData()
return m_sSkinData; return m_sSkinData;
} }
void CCSkin::updateTransform() void CCSkin::updateArmatureTransform()
{ {
m_sTransform = CCAffineTransformConcat(m_tSkinTransform, m_pBone->nodeToArmatureTransform()); m_sTransform = CCAffineTransformConcat(m_tSkinTransform, m_pBone->nodeToArmatureTransform());
} }
void CCSkin::draw() void CCSkin::updateTransform()
{ {
// If it is not visible, or one of its ancestors is not visible, then do nothing: // If it is not visible, or one of its ancestors is not visible, then do nothing:
if( !m_bVisible) if( !m_bVisible)

View File

@ -38,8 +38,8 @@ public:
public: public:
CCSkin(); CCSkin();
void updateArmatureTransform();
void updateTransform(); void updateTransform();
void draw();
CC_PROPERTY_PASS_BY_REF(CCBaseData, m_sSkinData, SkinData); CC_PROPERTY_PASS_BY_REF(CCBaseData, m_sSkinData, SkinData);
CC_SYNTHESIZE(CCBone *, m_pBone, Bone); CC_SYNTHESIZE(CCBone *, m_pBone, Bone);