RepeatForever not repeating issue

RepeatForever not repeating issue
0.0 0


Hi all,

I have a strange issue with RepeatForever at the moment; it’s not repeating the sequence at all. Repeat works fine (if I use X number of repeats), but RepeatForever doesn’t repeat a sequence, but simply stops at the end of the entire sequence. The code is exactly as follows:

Size visibleSize = Director::getInstance()->getVisibleSize();
meterSprite = Sprite::createWithSpriteFrameName("meter.png");
meterSprite->setAnchorPoint(Vec2(0, 0));

auto meterSize = meterSprite->getContentSize();

auto meterClippingNode = ClippingNode::create();
meterClippingNode->setAnchorPoint(Vec2(0, 0));
meterClippingNode->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2));

this->addChild(meterClippingNode, 1);

cocos2d::DrawNode *stencil = DrawNode::create();
stencil->drawSolidRect(Vec2(0, 0), Vec2(meterSize.width, meterSize.height), Color4F::MAGENTA);
stencil->setAnchorPoint(Vec2(0, 0));

auto moveBy = MoveBy::create(2, Vec2(0, -meterSize.height));
auto seq = Sequence::create(moveBy, moveBy->reverse(), nullptr);
auto rfe = RepeatForever::create(seq);  // Problem: Does not repeat the sequence 
// auto repeat = Repeat::create(seq, 10); // This works fine (repeats 10 times)

Is there something I’m doing wrong?

By the way, what this code does is move a stencil within a clipping area, with a sprite behind the stencil, so the sprite appears and disappears as the stencil moves down then up (and should repeat!).


what version of cocos2d-x are you using … i tried this on v3.14.1 and this code works fine


Latest branch with updates for the audio engine. I’ll try it with another version of cocos2d-x to see if it works.

EDIT: So it works fine with 3.14, but it doesn’t work in the 3.15 branch that I have checked out of GIT around 2 weeks ago. I’ll retest with the latest code (3.15rc0).

Issue was introduced in this merge:

It looks like it’s now fixed in the latest 3.15rc0 release.