From 61386b0a404af05555b73168397226cead5773d9 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 8 Jun 2017 14:52:36 +0800 Subject: [PATCH] fix the issue the sequence action will not be invoked (#17906) * fix the issue the sequence action will not be invoked * add comment * update _done in update() function --- cocos/2d/CCActionInstant.cpp | 27 +++++++++++++++++---------- cocos/2d/CCActionInterval.cpp | 6 ++++++ cocos/2d/CCActionInterval.h | 1 + 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/cocos/2d/CCActionInstant.cpp b/cocos/2d/CCActionInstant.cpp index 2a91c8dc35..7750cea87f 100644 --- a/cocos/2d/CCActionInstant.cpp +++ b/cocos/2d/CCActionInstant.cpp @@ -62,12 +62,11 @@ void ActionInstant::step(float /*dt*/) } #endif update(updateDt); - _done = true; } void ActionInstant::update(float /*time*/) { - // nothing + _done = true; } // @@ -86,8 +85,9 @@ Show* Show::create() return ret; } -void Show::update(float /*time*/) +void Show::update(float time) { + ActionInstant::update(time); _target->setVisible(true); } @@ -117,8 +117,9 @@ Hide * Hide::create() return ret; } -void Hide::update(float /*time*/) +void Hide::update(float time) { + ActionInstant::update(time); _target->setVisible(false); } @@ -148,8 +149,9 @@ ToggleVisibility * ToggleVisibility::create() return ret; } -void ToggleVisibility::update(float /*time*/) +void ToggleVisibility::update(float time) { + ActionInstant::update(time); _target->setVisible(!_target->isVisible()); } @@ -185,8 +187,9 @@ bool RemoveSelf::init(bool isNeedCleanUp) return true; } -void RemoveSelf::update(float /*time*/) +void RemoveSelf::update(float time) { + ActionInstant::update(time); _target->removeFromParentAndCleanup(_isNeedCleanUp); } @@ -225,8 +228,9 @@ bool FlipX::initWithFlipX(bool x) return true; } -void FlipX::update(float /*time*/) +void FlipX::update(float time) { + ActionInstant::update(time); static_cast(_target)->setFlippedX(_flipX); } @@ -264,8 +268,9 @@ bool FlipY::initWithFlipY(bool y) return true; } -void FlipY::update(float /*time*/) +void FlipY::update(float time) { + ActionInstant::update(time); static_cast(_target)->setFlippedY(_flipY); } @@ -316,8 +321,9 @@ Place * Place::reverse() const return this->clone(); } -void Place::update(float /*time*/) +void Place::update(float time) { + ActionInstant::update(time); _target->setPosition(_position); } @@ -405,8 +411,9 @@ CallFunc * CallFunc::reverse() const return this->clone(); } -void CallFunc::update(float /*time*/) +void CallFunc::update(float time) { + ActionInstant::update(time); this->execute(); } diff --git a/cocos/2d/CCActionInterval.cpp b/cocos/2d/CCActionInterval.cpp index 80aab92881..7f01e2f8fc 100644 --- a/cocos/2d/CCActionInterval.cpp +++ b/cocos/2d/CCActionInterval.cpp @@ -285,6 +285,12 @@ bool Sequence::initWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction return true; } +bool Sequence::isDone() const +{ + // fix issue #17884 + return (ActionInterval::isDone() && _actions[1]->isDone()); +} + Sequence* Sequence::clone() const { // no copy constructor diff --git a/cocos/2d/CCActionInterval.h b/cocos/2d/CCActionInterval.h index 7b6d5ed230..b431d3e3cf 100644 --- a/cocos/2d/CCActionInterval.h +++ b/cocos/2d/CCActionInterval.h @@ -185,6 +185,7 @@ public: virtual Sequence* reverse() const override; virtual void startWithTarget(Node *target) override; virtual void stop(void) override; + virtual bool isDone() const override; /** * @param t In seconds. */