Esempio n. 1
0
CCSpawn * ActionNode::refreshActionProperty()
{
	if ( m_Object == NULL )
	{
		return NULL;
	}
	CCArray* cSpawnArray = CCArray::create();
	for (int n = 0; n < frameArrayNum; n++)
	{
		CCArray* cArray = (CCArray*)(m_FrameArray->objectAtIndex(n));
		if (cArray == NULL || cArray->count() <= 0)
		{
			continue;
		}

		CCArray* cSequenceArray = CCArray::create();
		int frameCount = cArray->count();
		for (int i = 0; i < frameCount; i++)
		{
			ActionFrame* frame = (ActionFrame*)(cArray->objectAtIndex(i));
			if (i == 0)
			{
				CCAction* cAction = frame->getAction(0);
				cSequenceArray->addObject(cAction);
			}
			else
			{
				ActionFrame* srcFrame = (ActionFrame*)(cArray->objectAtIndex(i-1));
				float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex()) * getUnitTime();
				CCAction* cAction = frame->getAction(duration,srcFrame);
				cSequenceArray->addObject(cAction);
			}
		}
		CCSequence* cSequence = CCSequence::create(cSequenceArray);
		if (cSequence != NULL)
		{
			cSpawnArray->addObject(cSequence);
		}
	}

	if (m_action == NULL)
	{
		CC_SAFE_RELEASE_NULL(m_actionSpawn);
	}
	else
	{
		CC_SAFE_RELEASE_NULL(m_action);
	}

	m_actionSpawn = CCSpawn::create(cSpawnArray);
	CC_SAFE_RETAIN(m_actionSpawn);
	return m_actionSpawn;
}
Esempio n. 2
0
bool ActionNode::updateActionToTimeLine(float fTime)
{
	bool bFindFrame = false;

	ActionFrame* srcFrame = NULL;
	ActionFrame* destFrame = NULL;

	for (int n = 0; n < _frameArrayNum; n++)
	{
		Array* cArray = (Array*)(_frameArray->getObjectAtIndex(n));
		if (cArray == NULL)
		{
			continue;
		}
		int frameCount = cArray->count();
		for (int i = 0; i < frameCount; i++)
		{
			ActionFrame* frame = (ActionFrame*)(cArray->getObjectAtIndex(i));

			if (frame->getFrameIndex()*getUnitTime() == fTime)
			{
				this->easingToFrame(1.0f,1.0f,frame);
				bFindFrame = true;
				break;
			}
			else if (frame->getFrameIndex()*getUnitTime() > fTime)
			{
				if (i == 0)
				{
					this->easingToFrame(1.0f,1.0f,frame);
					bFindFrame = false;
				}
				else
				{
					srcFrame = (ActionFrame*)(cArray->getObjectAtIndex(i-1));
					float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex())*getUnitTime();
					float delaytime = fTime - srcFrame->getFrameIndex()*getUnitTime();
					this->easingToFrame(duration,1.0f,srcFrame);
					//float easingTime = ActionFrameEasing::bounceTime(delaytime);
					this->easingToFrame(duration,delaytime/duration,frame);
					bFindFrame = true;
				}
				break;
			}
		}
	}
	return bFindFrame;
}
Esempio n. 3
0
bool ActionNode::updateActionToTimeLine(float fTime)
{
	bool bFindFrame = false;

	ActionFrame* srcFrame = nullptr;
	//	ActionFrame* destFrame = nullptr;

	for (int n = 0; n < _frameArrayNum; n++)
	{
		auto cArray = _frameArray.at(n);
		if (cArray->empty())
		{
			continue;
		}
		ssize_t frameCount = cArray->size();
		for (int i = 0; i < frameCount; i++)
		{
			auto frame = cArray->at(i);

			if (frame->getFrameIndex()*getUnitTime() == fTime)
			{
				this->easingToFrame(1.0f,1.0f,nullptr,frame);
				bFindFrame = true;
				break;
			}
			else if (frame->getFrameIndex()*getUnitTime() > fTime)
			{
				if (i == 0)
				{
					this->easingToFrame(1.0f,1.0f,nullptr,frame);
					bFindFrame = false;
				}
				else
				{
					srcFrame = cArray->at(i-1);
					float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex())*getUnitTime();
					float delaytime = fTime - srcFrame->getFrameIndex()*getUnitTime();
					this->easingToFrame(duration,1.0f,nullptr,srcFrame);
					//float easingTime = ActionFrameEasing::bounceTime(delaytime);
					this->easingToFrame(duration,delaytime/duration,srcFrame,frame);
					bFindFrame = true;
				}
				break;
			}
		}
	}
	return bFindFrame;
}
Esempio n. 4
0
int ActionNode::getLastFrameIndex()
{
	int frameindex = -1;
	bool bFindFrame = false;
	for (int n = 0; n < frameArrayNum; n++)
	{
		CCArray* cArray = (CCArray*)(m_FrameArray->objectAtIndex(n));
		if (cArray == NULL || cArray->count() <= 0)
		{
			continue;
		}

		bFindFrame = true;
		int lastInex = cArray->count() - 1;
		ActionFrame* frame = (ActionFrame*)(cArray->objectAtIndex(lastInex));
		int iFrameIndex = frame->getFrameIndex();

		if (frameindex < iFrameIndex)
		{
			frameindex = iFrameIndex;
		}
	}
	if (!bFindFrame)
	{
		frameindex = 0;
	}
	return frameindex;
}
Esempio n. 5
0
int ActionNode::getFirstFrameIndex()
{
	int frameindex = 99999;
	bool bFindFrame = false;
	for (int n = 0; n < _frameArrayNum; n++)
	{
		Array* cArray = (Array*)(_frameArray->getObjectAtIndex(n));
		if (cArray == NULL || cArray->count() <= 0)
		{
			continue;
		}
		bFindFrame = true;
		ActionFrame* frame = (ActionFrame*)(cArray->getObjectAtIndex(0));
		int iFrameIndex = frame->getFrameIndex();

		if (frameindex > iFrameIndex)
		{
			frameindex = iFrameIndex;
		}
	}
	if (!bFindFrame)
	{
		frameindex = 0;
	}
	return frameindex;
}