Search code examples
cocos2d-xcocos2d-js

cocos2d-js: cc.delayTime() and cc.repeatForever() don't work together in cc.sequence()


I try to animate three circles with cc.scaleTo() and it works fine up to the moment when i combine cc.delayTime() and cc.repeatForever(). In the hello worlds app I added:

 /////////////////////////////
    // 3. add your codes below...

    var contacts = [];

    for( var i=0 ; i<3 ; i++ ) {
        contacts[i] = cc.DrawNode.create();
        contacts[i].retain();
        contacts[i].clear();
        contacts[i].setScale(1);
        contacts[i].drawCircle(cc.p(0,0), 30, 0, 100, false, 2, cc.color(255,0,0,255));
        contacts[i].setPosition(size.width/2, size.height/2);
        this.addChild(contacts[i]);

        contacts[i].runAction(
            cc.sequence(
                cc.delayTime(i),
                cc.repeatForever(
                    cc.sequence(
                        cc.scaleTo(3, 3),
                        cc.scaleTo(0.01, 0)
                    )
                )
            )
        );
    }
    return true;

This is not working and shows the console message:

[Action update]. override me

When I remove either: cc.delayTime() or cc.repeatForever() it works fine.

contacts[i].runAction(
       cc.sequence(
           cc.repeatForever(
                cc.sequence(
                    cc.scaleTo(3, 3),
                    cc.scaleTo(0.01, 0)
                )
            )
        )
);

or

contacts[i].runAction(
        cc.sequence(
            cc.delayTime(i),
            cc.sequence(
                cc.scaleTo(3, 3),
                cc.scaleTo(0.01, 0)
            )
        )
);

And no message appears.

What could that be?


Solution

  • you can't put cc.RepeatForever into cc.Sequence, it will not repeat

    only finite time actions can be put into sequence