Action Animate before DelayTime

Hello,

I am learning animation and action in cocos html5 2.2.1. I have multiple objects to animate, and the following code works perfectly fine:

var animation = cc.Animation.create(gRailMatrix.mAnyFrames,0.4);  
this.runAction(
        cc.RepeatForever.create(cc.Animate.create(animation)));

Creates animation and repeats it forever. However, the number of object is 5-10 all of them are animated the same way (synchronized). In order to dissynchronize I add random delay time befer the repeatforever action (delay time is from 0 to 0.1 seconds):

    var animation = cc.Animation.create(gRailMatrix.mAnyFrames,0.4);  
    var rand = Math.random();
    var temp = rand * 0.1;             
    this.runAction(
        cc.Sequence.create(
            cc.DelayTime.create(temp),
            cc.RepeatForever.create(cc.Animate.create(animation))));

Unfortunately this code stops to work and animation is never shown. Is it bug, or I am doing something wrong?

1 Like

Yes it is a bug~~
One way to work around is try to put your Reapeat Event in a callback func after delay time

Hi laser,

cc.RepeatForever has a warning that “This action can’t be Sequencable because it is not an IntervalAction”.
And ZiJian’s suggest is right.

Bests
David