google-code-export / los-cocos

Automatically exported from code.google.com/p/los-cocos
Other
1 stars 0 forks source link

AccelDeccel wrapped actions do not properly receive a call to update() when t=1.0 #171

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
AccelDeccel wrapped actions do not properly receive a call to update() when 
t=1.0.

I have written my own actions that expect their update() function to follow the 
rules that were defined in the reference guide located here 
"http://cocos2d.org/doc/programming_guide/creating_your_own_actions.html".

These rules specifically...

* update(t) will most likely be called many time with t in [0,1) and t will 
monotonically rise.
* update(1) will be called.
* stop() will be called.

For my environment my subclassed IntervalActions do not receive the call to 
update(1) as promised above when wrapped with the AccelDeccel action. I get 
values of update() where t=0.9 but never 1.0. So to me this indicates that 
AccelDeccel violates the rules for wrapped actions and taints their behavior 
beyond the simple speed up,slow down concept.

I applied a very simple patch to correct the issue for my use case but I wanted 
to check if this is truly a bug or not in your eyes. The mapped value of t 
follows the equation but the *last* value where t=1.0 is translated to a value 
where t<1.0 and my child actions can no longer detect the last call to update() 
where I have some special logic.

Here is my subclassed class that corrects the behavior.

from cocos.actions import AccelDeccel

""" Modified AccelDeccel class that properly guarantees update(1.0) will be 
called """
class FixedAccelDeccel(AccelDeccel):
    def update(self, t):
        #print 't=%s' % t
        ft = (t-0.5) * 12
        nt = 1./( 1. + math.exp(-ft) )

        #Unlike the Superclass, properly pass 1.0 through
        if t == 1.0:
            self.other.update( 1.0 )
            return
        self.other.update( nt )

Python 2.7.2 and cocos2d 0.5.0

Original issue reported on code.google.com by AcidTo...@gmail.com on 15 Jan 2012 at 9:31

GoogleCodeExporter commented 9 years ago
Thanks for the report !

unit test added at r1166
fixed at r1167

(releaser: close this issue after next cocos release)  

Original comment by ccanepacc@gmail.com on 25 Jan 2012 at 9:21

GoogleCodeExporter commented 9 years ago

Original comment by ccanepacc@gmail.com on 26 Feb 2012 at 4:55

GoogleCodeExporter commented 9 years ago
fixed in cocos 0.5.5, closing

Original comment by ccanepacc@gmail.com on 14 Aug 2012 at 12:53