diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index b08af1d1e..b22847742 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -40,14 +40,21 @@ NS_CC_BEGIN // // InstantAction // +void ActionInstant::startWithTarget(Node *target) +{ + FiniteTimeAction::startWithTarget(target); + _done = false; +} + bool ActionInstant::isDone() const { - return true; + return _done; } void ActionInstant::step(float dt) { CC_UNUSED_PARAM(dt); update(1); + _done = true; } void ActionInstant::update(float time) { diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index c60a78918..cc1d7651d 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -51,11 +51,14 @@ class CC_DLL ActionInstant : public FiniteTimeAction // // // Overrides // + virtual void startWithTarget(Node *target) override; virtual ActionInstant* clone() const override { CC_ASSERT(0); return nullptr; } virtual ActionInstant * reverse(void) const override { CC_ASSERT(0); return nullptr; } virtual bool isDone(void) const override; virtual void step(float dt) override; virtual void update(float time) override; +private: + bool _done; }; /** @brief Show the node diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index f4b24a99a..e79b00b94 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -103,13 +103,14 @@ bool ActionInterval::initWithDuration(float d) _elapsed = 0; _firstTick = true; + _done = false; return true; } bool ActionInterval::isDone(void) const { - return _elapsed >= _duration; + return _done; } void ActionInterval::step(float dt) @@ -130,6 +131,8 @@ void ActionInterval::step(float dt) ) ) ); + + _done = _elapsed >= _duration; } void ActionInterval::setAmplitudeRate(float amp) diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index 006e030b6..f37127833 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -84,7 +84,8 @@ class CC_DLL ActionInterval : public FiniteTimeAction protected: float _elapsed; - bool _firstTick; + bool _firstTick; + bool _done; }; /** @brief Runs actions sequentially, one after another