Search code examples
javascriptcocos2d-js

Error when executing cc.RepeatForever() cocos2d-js


when i execute:

var repeat_sprite = cc.Repeat.create(cc.Place.create(cc.p(10, 10)), 5);
sprite.runAction(repeat_sprite);

it worked bout when i tried this one:

var repeat_sprite = cc.RepeatForever.create(cc.Place.create(cc.p(10, 10)));
sprite.runAction(repeat_sprite);

it gives me this error in the console:

TypeError: locInnerAction.getElapsed is not a function

i don't know if the error is on my script or in the cocos source.

PD.: i also tried:

cc.repeatForever(action);

it didn't work either.

already thanks for the help.


Solution

  • So in the beginning, you shouldn't use the .create()-function anymore. To do it right, the syntax is like this:

    var repeat_sprite = cc.repeatForever(cc.place(cc.p(10,10)));
    

    But I also tried your code and however it seems to be a logical problem. If you place an item, you normally do it just once it doesn't make sense to do it all over again. If you try cc.repeatForever with other actions it will work ;)