求解CCAction的问题

我的精灵要播放前后左右的动画 我已经写成了CCAction
可以开始用sprite->runAction(upAction):
当我要播放向下动画的时候 我这样写 sprite->stopAction(upAction); sprite->runAction(downAction);
这个Action是精灵的动画 不是位置的移动 这样会出现错误 求解

332
还有我想知道 Action->isDone有没有作用了,现在。。。。我调用了 完全没有反应 求解答 感激不尽

看样子好像是引用问题,检查下upAction和downAction是不是引用了相同的自动释放的对象,在upAction被stop的情况下,该对象引用计数设置为0了,导致runAction(downAction)运行时使用了reference为0的对象。

— Begin quote from ____

85964596 发表于 2012-7-20 01:26 url

看样子好像是引用问题,检查下upAction和downAction是不是引用了相同的自动释放的对象,在upAction被stop的 …

— End quote

333
这就是upAction
upAction= AnimateHelper::m_Action(“Images/donghua.png”, 124, 192, 1);//向上走

#include "cocos2d.h"

using namespace cocos2d;

class AnimateHelper
{
public: 
	static CCAction* m_Action(const char *fname,int length, int highth, int flag)
	{
		CCTexture2D *mode = CCTextureCache::sharedTextureCache()->addImage(fname);
		CCArray *m_frames  = new CCArray();
		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				CCSpriteFrame *frame = CCSpriteFrame::frameWithTexture(mode,CCRectMake(j * length / 4, i * highth / 4, length / 4, highth / 4));
				m_frames->addObject(frame);
			}	
		}

		int a = 0, b = 0;
		if (flag == 0)
		{
			a = 0;b = 4;
		}else if (flag == 1)
		{
			a = 4;b = 8;
		}else if (flag == 2)
		{
			a = 8;b = 12;
		}else if (flag == 3)
		{
			a = 12;b = 16;
		}
		CCLog("a = %d, b = %d", a, b);

		CCArray *temp = new CCArray();
		for (int i = a; i < b; i++)
		{
			temp->addObject(m_frames->objectAtIndex(i));
		}

		CCAnimation *m_ani = CCAnimation::animationWithSpriteFrames(temp, 0.2f);
		CCAnimate *m_action = CCAnimate::actionWithAnimation(m_ani);
		CCAction *tempAction = CCRepeatForever::actionWithAction(m_action);
		return tempAction;
		//return m_action;
	}
};

哪里有自动释放。。。。

已经解决了。。。。我引用了一个已经被释放的对象!!!

在创建Action的时候 写个retain()

看样子好像是引用问题,检查下upAction和downAction是不是引用了相同的自动释放的对象,在upAction被stop的情况下,该对象引用计数设置为0了,导致runAction(downAction)运行时使用了reference为0的对象。