The CallFunc is not called at the end of repeat

  • sorry I had posted this in Javascript binding, deleting that and posting here again *

I am facing an issue where the function at the end of a sequence when used with cc.Repeat does not get called.

I modified the HelloWorld HTML5

@
var fireLoopStart = cc.CallFunc.create(this.fireLoopStart, this);
var fireLoopEnd = cc.CallFunc.create(this.fireLoopEnd, this);

var rotateBy1 = cc.RotateBy.create(1, 10);
var rotateBy2 = cc.RotateBy.create(1, –10);

this.sprite.runAction(cc.Repeat.create(cc.Sequence.create(fireLoopStart, rotateBy1, rotateBy2, fireLoopEnd), 2));
@

I think the expected sequence should be following, which by the way works fine with JSB, the problem is only with html5

fireLoopStart
rotateBy1
rotateBy2
fireLoopEnd
fireLoopStart
rotateBy1
rotateBy2
fireLoopEnd ( This is never called )

Am I doing anything wrong here? it works as I expect on iOS simulator with JSB.

Any help to solve this issue would be much appreciated.

I have attached the modified MyApp.js file

Thanks
Shuja


myApp.js.zip (2.2 KB)

try this code
this.sprite.runAction(cc.Repeat.create(cc.Sequence.create(fireLoopStart, fireLoopEnd), 2));
it only print 1 time.

I debug the js, ‘repeat action’ will calculate the time of the whold action. but the ‘callfunc action’ is instant action, that mean the time span is very short.
the first tick, execute your two ‘callfunc action’. the second tick, the time elaspe longer than ‘repeat action’. ‘repeat action’ find out weather the ‘Sequence action’ is done or not.
the ‘callfunc action’ is instant action, instant action always is done. so ‘repeat action’ think it is execute over, then finish.

If you try this in iOS with Javascript Bindings, it will call callfunc correctly even in the second loop. So I think the way it has been implemented in cocos2d-x and cocos2d-html5 is different.

Any workarounds for this?