A bug of RepeatForever

16 views
Skip to first unread message

huabing.xu

unread,
Jun 16, 2014, 6:30:00 AM6/16/14
to Ricardo Quesada, cocos2d-js-devel, cocos3d-x-devel

Hi, when I was debugging code for Animation. I found a bug in RepeatForever. Here is the code snap:


void RepeatForever::step(float dt)

{

    _innerAction->step(dt);

    if (_innerAction->isDone())

    {

        float diff = _innerAction->getElapsed() - _innerAction->getDuration();

        _innerAction->startWithTarget(_target);

        // to prevent jerk. issue #390, 1247

        _innerAction->step(0.0f);

        _innerAction->step(diff);

    }

}


However, if this is a super large dt, the diff will be larger than _innerAction->getDuration(). So there could be a freeze time here.

It is better to use 

float diff = fmodf(_innerAction->getElapsed(), _innerAction->getDuration())

instead.


Any ideas about this? It you agree, I will fix it like this.


Thanks


Best Regards
Harrison Xu

Dawid Drozd

unread,
Jun 16, 2014, 9:18:59 AM6/16/14
to huabing.xu, Ricardo Quesada, cocos2d-js-devel, cocos3d-x-devel
Yeah it was reported in one of PR even on forum.



--
You received this message because you are subscribed to the Google Groups "cocos2d JS development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos2d-js-dev...@googlegroups.com.
To post to this group, send email to cocos2d-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Pozdrawiam
Dawid Drozd.
Reply all
Reply to author
Forward
0 new messages