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):
this~~>addChild;
sprite~~>runAction(animate);
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.
EDIT::
I looked to this post (http://www.cocos2d-x.org/boards/6/topics/7553) 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)