Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17115

RepeatForever bug?

$
0
0

@piotrros wrote:

I've created very simple animation which moves a balloon up and down:

    auto _action = RepeatForever::create(Sequence::create(MoveBy::create(1.0f, Vec2(0, 60)), MoveBy::create(1.0f, Vec2(0, -60)), NULL));
    balloonNode->runAction(_action);

Works.

Now I wanted to add a small random delay so not every balloon will start at the same time:

    float t = rand_0_1();
    auto _action = RepeatForever::create(Sequence::create(MoveBy::create(1.0f, Vec2(0, 60)), MoveBy::create(1.0f, Vec2(0, -60)), NULL));
    auto action = Sequence::createWithTwoActions(DelayTime::create(t), _action);
    balloonNode->runAction(action);

Doesn't work. Nothing's moving. Variable "t" is ok. I printed it and it has correct value (between 0 and 1). I've also tried any fixed "t".

Now I've created alternative version using Repeat instead:

    float t = rand_0_1();
    auto _action = Repeat::create(Sequence::create(MoveBy::create(1.0f, Vec2(0, 60)), MoveBy::create(1.0f, Vec2(0, -60)), NULL), -1);
    auto action = Sequence::createWithTwoActions(DelayTime::create(t), _action);
    balloonNode->runAction(action);

Works like a charm.

Why version with RepeatForever doesn't work?

Posts: 8

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 17115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>