Skip to content

Commit

Permalink
Fix instant/interval actions done check
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk committed Apr 17, 2017
1 parent cfba8a1 commit 7fcd56c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion cocos2dx/actions/CCActionInstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions cocos2dx/actions/CCActionInstant.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ class CC_DLL ActionInstant : public FiniteTimeAction //<NSCopying>
//
// 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
Expand Down
5 changes: 4 additions & 1 deletion cocos2dx/actions/CCActionInterval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -130,6 +131,8 @@ void ActionInterval::step(float dt)
)
)
);

_done = _elapsed >= _duration;
}

void ActionInterval::setAmplitudeRate(float amp)
Expand Down
3 changes: 2 additions & 1 deletion cocos2dx/actions/CCActionInterval.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7fcd56c

Please sign in to comment.