Crash in CCSequence::create

I’m porting code from cocos2d-iphone.
All things works file until these code crashes with Assertion failed: (m_uReference > 0), function retain

CCDelayTime *dt1 = CCDelayTime::create(1); CCShow *sh1 = CCShow::create(); CCScaleTo *st1 = CCScaleTo::create(0.2f, 1.5f); CCScaleTo *st2 = CCScaleTo::create(0.1f, 1); CCSequence *sq = CCSequence::create(dt1, sh1, st1, st2); mNew->runAction(sq);

Program crash in CCSequence::create
Any ideas?

i think on CCDelayTime dt1 = CCDelayTime::create; and CCScaleTost2 = CCScaleTo::create(0.1f, 1)

if i remember it should be
CCDelayTime dt1 = CCDelayTime::create; and CCScaleTost2 = CCScaleTo::create(0.1f, 1.0f)

Wibowo Raditya wrote:

i think on CCDelayTime dt1 = CCDelayTime::create; and CCScaleTost2 = CCScaleTo::create(0.1f, 1)
>
if i remember it should be
CCDelayTime dt1 = CCDelayTime::create; and CCScaleTost2 = CCScaleTo::create(0.1f, 1.0f)

You mean use 1.0f instead of 1?
I dont think so. The compiler should cast 1 to float type.
However since this problem is really a wired one, I changed my code as below, and the trouble is not disappeared.

CCDelayTime *dt1 = CCDelayTime::create(1.0f); CCShow *sh1 = CCShow::create(); CCScaleTo *st1 = CCScaleTo::create(0.2f, 1.5f); CCScaleTo *st2 = CCScaleTo::create(0.1f, 1.0f);

And I tried to put those actions in an array and create the sequence with action array like below:

CCArray *sqa = CCArray::create(dt1, sh1, st1, st2); CCSequence *sq = CCSequence::create(sqa);

Then a found the program crash when executing CCArray::create.
So it seems that the problem is in the creation of actions. And even I sat a breakpoint before CCArray::create, And found the reference count is all right.
But the error still exist.

issue resolved.
I use CCArray::create() and then call addObject to each action. the problem is disappeared.
I think the problem may caused by the way of xcode compiler process the var_list. Since this is the only difference of two version of code, but I’m not sure.

Variable argument functions like this in Cocos2d-x tend to be null terminated.

In your example if you did:

CCSequence *sq = CCSequence::create(dt1, sh1, st1, st2, NULL);
This would resolve your problems.

That’s it! Thank you for pointing this out.

Stuart McGaw wrote:

Variable argument functions like this in Cocos2d-x tend to be null terminated.
>
In your example if you did:
>
CCSequence *sq = CCSequence::create(dt1, sh1, st1, st2, NULL);
This would resolve your problems.