diff --git a/extensions/CCArmature/CCArmature.cpp b/extensions/CCArmature/CCArmature.cpp index 76055e7c3a..bfd0fcbf64 100644 --- a/extensions/CCArmature/CCArmature.cpp +++ b/extensions/CCArmature/CCArmature.cpp @@ -460,7 +460,7 @@ void CCArmature::draw() if (m_pAtlas->getCapacity() == m_pAtlas->getTotalQuads() && !m_pAtlas->resizeCapacity(m_pAtlas->getCapacity() * 2)) return; - skin->draw(); + skin->updateTransform(); } else if(CCArmature *armature = dynamic_cast(node)) { diff --git a/extensions/CCArmature/animation/CCTween.cpp b/extensions/CCArmature/animation/CCTween.cpp index 59402f851e..ec21561e9b 100644 --- a/extensions/CCArmature/animation/CCTween.cpp +++ b/extensions/CCArmature/animation/CCTween.cpp @@ -83,6 +83,7 @@ bool CCTween::init(CCBone *bone) m_pBone = bone; m_pTweenData = m_pBone->getTweenData(); + m_pTweenData->displayIndex = -1; 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_bIsTweenKeyFrame = false; m_iTotalDuration = 0; betweenDuration = 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) { m_eLoopType = SINGLE_FRAME; - CCFrameData *_nextKeyFrame = m_pMovementBoneData->getFrameData(0); - if(_durationTo == 0) + if(durationTo == 0) { - setBetween(_nextKeyFrame, _nextKeyFrame); + setBetween(nextKeyFrame, nextKeyFrame); } else { - m_pTweenData->displayIndex = _nextKeyFrame->displayIndex; - setBetween(m_pTweenData, _nextKeyFrame); + setBetween(m_pTweenData, nextKeyFrame); } - m_bIsTweenKeyFrame = true; m_eFrameTweenEasing = Linear; m_iRawDuration = m_pMovementBoneData->duration; m_iFromIndex = m_iToIndex = 0; } else if (m_pMovementBoneData->frameList.count() > 1) { - if (_loop) + if (loop) { m_eLoopType = ANIMATION_TO_LOOP_BACK; m_iRawDuration = m_pMovementBoneData->duration; @@ -141,18 +141,22 @@ void CCTween::play(CCMovementBoneData *_movementBoneData, int _durationTo, int _ 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)); - } else { - CCFrameData *_nextKeyFrame = m_pMovementBoneData->getFrameData(0); - setBetween(m_pTweenData, _nextKeyFrame); - m_bIsTweenKeyFrame = true; + if (!difMovement) + { + setBetween(nextKeyFrame, nextKeyFrame); + } + else + { + setBetween(m_pTweenData, nextKeyFrame); + } } } @@ -272,18 +276,18 @@ void CCTween::setBetween(CCFrameData *from, CCFrameData *to) { 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_pBetween->subtract(to, to); break; } - else if(from->displayIndex < 0 && to->displayIndex > 0) - { - m_pFrom->copy(to); - m_pBetween->subtract(to, to); - break; - } m_pFrom->copy(from); m_pBetween->subtract(from, to); diff --git a/extensions/CCArmature/animation/CCTween.h b/extensions/CCArmature/animation/CCTween.h index c14605d59b..328a8d250c 100644 --- a/extensions/CCArmature/animation/CCTween.h +++ b/extensions/CCArmature/animation/CCTween.h @@ -130,8 +130,6 @@ protected: CCTweenType m_eFrameTweenEasing; //! Dedermine which tween effect current frame use - bool m_bIsTweenKeyFrame; - int betweenDuration; //! Current key frame will last betweenDuration frames int m_iTotalDuration; diff --git a/extensions/CCArmature/display/CCDisplayFactory.cpp b/extensions/CCArmature/display/CCDisplayFactory.cpp index d8b48950a1..efc9fc0334 100644 --- a/extensions/CCArmature/display/CCDisplayFactory.cpp +++ b/extensions/CCArmature/display/CCDisplayFactory.cpp @@ -185,7 +185,7 @@ void CCDisplayFactory::createSpriteDisplay(CCBone *bone, CCDecorativeDisplay *de void CCDisplayFactory::updateSpriteDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay, float dt, bool dirty) { CCSkin *skin = (CCSkin *)decoDisplay->getDisplay(); - skin->updateTransform(); + skin->updateArmatureTransform(); } diff --git a/extensions/CCArmature/display/CCSkin.cpp b/extensions/CCArmature/display/CCSkin.cpp index 3b776a5c2e..2aeb12b83d 100644 --- a/extensions/CCArmature/display/CCSkin.cpp +++ b/extensions/CCArmature/display/CCSkin.cpp @@ -79,12 +79,12 @@ const CCBaseData &CCSkin::getSkinData() return m_sSkinData; } -void CCSkin::updateTransform() +void CCSkin::updateArmatureTransform() { 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( !m_bVisible) diff --git a/extensions/CCArmature/display/CCSkin.h b/extensions/CCArmature/display/CCSkin.h index aa47224425..4c145f2ea6 100644 --- a/extensions/CCArmature/display/CCSkin.h +++ b/extensions/CCArmature/display/CCSkin.h @@ -38,8 +38,8 @@ public: public: CCSkin(); + void updateArmatureTransform(); void updateTransform(); - void draw(); CC_PROPERTY_PASS_BY_REF(CCBaseData, m_sSkinData, SkinData); CC_SYNTHESIZE(CCBone *, m_pBone, Bone);