CCAnimate Causing Crash

CCAnimate Causing Crash
0.0 0


I’m trying to animate a sprite while it’s moving. As per the examples: I create an array of frames, create a CCAnimation with them (and a delay), and then create the CCAnimate from that. When I do the following (in the constructor where animate is made):


It works fine.

When I try to run a certain animation while it moves in a different method (animate is a global pointer to the animation) I get the following error:

In function retain — …cpp:92 m_uReference > 0 — assertion failed

Or more specifically: CCAssert(m_uReference > 0, “reference count should greater than 0”);

There is nothing null as far as I can see.


I looked to this post ( and added a CC_SAFE_RETAIN(animate) and CC_SAFE_RETAIN(display) in the init method.
Now I see the first image of the animation but it crashes right after saying:
In function addAction — …cpp:191 ! ccArrayContainsObject(pElement->actions, pAction) — assertion failed
Unfortunately it doesn’t give a helpful message when I go to that spot in the code. (It just has “” as it’s message)


I figured out the problem.

Essentially follow the example here:

The second part was that the action was being run twice, which is why that error was thrown.
It was a logic error on my part (I’m using a custom CCNode child class)
I overrode the ‘numberOfRunningActions’ to take into account both the custom class and the sprite


@aol , u r link not working. it redirect to main forum. i have similar issue… plz check aND REPLY THERE. Crash on CCAnimation