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

Is this a CallFunc with Spawn bug?

$
0
0

@naghekyan wrote:

Here is the code I use:

CallFunc* logFunc = CallFunc::create([] ()
{
    static int i = 0;
    CCLOG("CALL %d", i);
    ++i;
});

Vector<FiniteTimeAction*> vec;
for (int i = 0; i < 5; ++i)
{
    vec.pushBack(logFunc);
}

Sequence* spAct = Sequence::create(vec);

runAction(spAct);

The log is as follows:

CALL 0
CALL 1
CALL 2
CALL 3
CALL 4

If I change the code to read Sequence as Spawn i.e.

CallFunc* logFunc = CallFunc::create([] ()
{
    static int i = 0;
    CCLOG("CALL %d", i);
    ++i;
});

Vector<FiniteTimeAction*> vec;
for (int i = 0; i < 5; ++i)
{
    vec.pushBack(logFunc);
}

Spawn* spAct = Spawn::create(vec);

runAction(spAct);

the log is the following:

CALL 0
CALL 1
CALL 2
CALL 3
CALL 4
CALL 5
CALL 6

I have debugged and the fact is that first two actions in Vector<FiniteTimeAction*> vec; are being called twice at the end, i.e. CALL 0 and 1 are the same actions as CALL 5 and 6 correspondingly. I use cocos2d-x-3.8.1 ( September.17 2015) so I am not sure if this bug is present in the latest version too. Please respond if you have such issues too so that we would open an issue in Github.

@ricardo @slackmoehrle @nite @zhangxm

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 17118

Latest Images

Trending Articles



Latest Images

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