Repeat bug? My mind is blown

Consider this example:

root->runAction(CallFunc::create([&]() {
        CCLOG("repeat A");
}));

Prints “repeat A”.

root->runAction(Repeat::create(CallFunc::create([&]() {
        CCLOG("repeat B");
}), 1));

It should print “repeat B”, right? It’s not writing anything… Also breakpoint is not triggering.

But this:

root->runAction(
                    Repeat::create(
                                   Sequence::createWithTwoActions(
                                                                  CallFunc::create([&]() {
                                                                       CCLOG("repeat C");
                                                                   }),
                                                                  DelayTime::create(0.25f)
                    ), 1)
);

Prints “repeat C”.

Last example:

root->runAction(Repeat::create(Sequence::createWithTwoActions(
                                                                  CallFunc::create([&]() {
                                                                    CCLOG("repeat D");
                                                                  }),
                                                                  DelayTime::create(0.1f)
                                                                  ), 3));

Prints “repeat D” 4 times instead of 3! I’ve figured out that changing delay to 0.25f fixes the problem.

What’s going on?

What version of Cocos2d-x is this?

3.10 of course.

Alright, I am happy to look into this.

Looking forward to it!

I’ll try this today. Sorry for the delay. I was off for a few days.

Weird, this seems like a total bug.

This is what I did:

auto root = cocos2d::Node::create();
    addChild(root);
    
    root->runAction(CallFunc::create([&]() {
        CCLOG("repeat A");
    }));
    
    root->runAction(Repeat::create(CallFunc::create([&]() {
        CCLOG("repeat B");
    }), 1));
    
    root->runAction(Repeat::create(Sequence::createWithTwoActions(
        CallFunc::create([&]() { CCLOG("repeat C");}),
        DelayTime::create(0.25f)),
        1)
    );
    
    root->runAction(Repeat::create(Sequence::createWithTwoActions(
        CallFunc::create([&]() { CCLOG("repeat D");}),
        DelayTime::create(0.1f)),
        3)
    );

and the output:

repeat A
repeat C
repeat D
repeat D
repeat D
repeat D

No repeat B and breakpoint doesn’t halt execution either. and repeat D repeats 4 times instead of 3

@piotrros https://github.com/cocos2d/cocos2d-x/pull/15348

Great! It’s working now! Thanks for your help! (now gradle support plz :D)

I am not sure we can add that as quickly as this was fixed :slight_smile: