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));
meterSprite->setPositionY(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));
stencil->setPositionY(0);
meterClippingNode->setStencil(stencil);
meterClippingNode->addChild(meterSprite);
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)
stencil->runAction(rfe);
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!).