2011-03-19 10:34:26 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010-2011 cocos2d-x.org
|
|
|
|
Copyright (c) 2008-2009 Jason Booth
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-08-10 14:02:13 +08:00
|
|
|
/*
|
|
|
|
* Elastic, Back and Bounce actions based on code from:
|
|
|
|
* http://github.com/NikhilK/silverlightfx/
|
|
|
|
*
|
|
|
|
* by http://github.com/NikhilK
|
|
|
|
*/
|
2011-03-19 10:34:26 +08:00
|
|
|
|
|
|
|
#include "CCActionEase.h"
|
|
|
|
#include "CCObject.h"
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_BEGIN
|
2010-08-10 14:02:13 +08:00
|
|
|
|
|
|
|
#ifndef M_PI_X_2
|
|
|
|
#define M_PI_X_2 (float)M_PI * 2.0f
|
|
|
|
#endif
|
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
//
|
|
|
|
// EaseAction
|
|
|
|
//
|
|
|
|
CCActionEase* CCActionEase::actionWithAction(CCActionInterval *pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionEase *pRet = new CCActionEase();
|
|
|
|
if (pRet)
|
|
|
|
{
|
2012-04-19 10:46:37 +08:00
|
|
|
if (pRet->initWithAction(pAction))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CCActionEase::initWithAction(CCActionInterval *pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert(pAction != NULL, "");
|
2012-04-19 10:46:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if (CCActionInterval::initWithDuration(pAction->getDuration()))
|
|
|
|
{
|
|
|
|
m_pOther = pAction;
|
|
|
|
pAction->retain();
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return false;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCObject* CCActionEase::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCActionEase* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCActionEase*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCActionEase();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
2012-04-19 10:46:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval::copyWithZone(pZone);
|
2012-04-19 10:46:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCActionEase::~CCActionEase(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CC_SAFE_RELEASE(m_pOther);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCActionEase::startWithTarget(CCNode *pTarget)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval::startWithTarget(pTarget);
|
|
|
|
m_pOther->startWithTarget(m_pTarget);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCActionEase::stop(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->stop();
|
|
|
|
CCActionInterval::stop();
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCActionEase::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->update(time);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCActionInterval* CCActionEase::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCActionEase::actionWithAction(m_pOther->reverse());
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseRateAction
|
|
|
|
//
|
|
|
|
CCEaseRateAction* CCEaseRateAction::actionWithAction(CCActionInterval *pAction, float fRate)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseRateAction *pRet = new CCEaseRateAction();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction, fRate))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
bool CCEaseRateAction::initWithAction(CCActionInterval *pAction, float fRate)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
if (CCActionEase::initWithAction(pAction))
|
|
|
|
{
|
|
|
|
m_fRate = fRate;
|
|
|
|
return true;
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return false;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCObject* CCEaseRateAction::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseRateAction* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseRateAction*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseRateAction();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
pCopy->initWithAction((CCActionInterval*)(m_pOther->copy()->autorelease()), m_fRate);
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCEaseRateAction::~CCEaseRateAction(void)
|
|
|
|
{
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCActionInterval* CCEaseRateAction::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseRateAction::actionWithAction(m_pOther->reverse(), 1 / m_fRate);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
//
|
|
|
|
// EeseIn
|
|
|
|
//
|
|
|
|
CCEaseIn* CCEaseIn::actionWithAction(CCActionInterval *pAction, float fRate)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseIn *pRet = new CCEaseIn();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction, fRate))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseIn::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseIn* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseIn*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseIn();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
pCopy->initWithAction((CCActionInterval*)(m_pOther->copy()->autorelease()), m_fRate);
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCEaseIn::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->update(powf(time, m_fRate));
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
//
|
|
|
|
// EaseOut
|
|
|
|
//
|
|
|
|
CCEaseOut* CCEaseOut::actionWithAction(CCActionInterval *pAction, float fRate)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseOut *pRet = new CCEaseOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction, fRate))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCObject* CCEaseOut::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseOut* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseOut*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseOut();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
pCopy->initWithAction((CCActionInterval*)(m_pOther->copy()->autorelease()), m_fRate);
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCEaseOut::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->update(powf(time, 1 / m_fRate));
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
//
|
|
|
|
// EaseInOut
|
|
|
|
//
|
|
|
|
CCEaseInOut* CCEaseInOut::actionWithAction(CCActionInterval *pAction, float fRate)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseInOut *pRet = new CCEaseInOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction, fRate))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseInOut::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseInOut* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseInOut*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseInOut();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
pCopy->initWithAction((CCActionInterval*)(m_pOther->copy()->autorelease()), m_fRate);
|
2012-04-19 10:46:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
void CCEaseInOut::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
int sign = 1;
|
|
|
|
int r = (int) m_fRate;
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if (r % 2 == 0)
|
|
|
|
{
|
|
|
|
sign = -1;
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
time *= 2;
|
2012-04-19 10:46:37 +08:00
|
|
|
if (time < 1)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
m_pOther->update(0.5f * powf(time, m_fRate));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_pOther->update(sign * 0.5f * (powf(time - 2, m_fRate) + sign * 2));
|
|
|
|
}
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
// InOut and OutIn are symmetrical
|
|
|
|
CCActionInterval* CCEaseInOut::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseInOut::actionWithAction(m_pOther->reverse(), m_fRate);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
//
|
|
|
|
// EaseExponentialIn
|
|
|
|
//
|
|
|
|
CCEaseExponentialIn* CCEaseExponentialIn::actionWithAction(CCActionInterval* pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseExponentialIn *pRet = new CCEaseExponentialIn();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseExponentialIn::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseExponentialIn* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseExponentialIn*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseExponentialIn();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCEaseExponentialIn::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->update(time == 0 ? 0 : powf(2, 10 * (time/1 - 1)) - 1 * 0.001f);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCActionInterval* CCEaseExponentialIn::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseExponentialOut::actionWithAction(m_pOther->reverse());
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseExponentialOut
|
|
|
|
//
|
|
|
|
CCEaseExponentialOut* CCEaseExponentialOut::actionWithAction(CCActionInterval* pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseExponentialOut *pRet = new CCEaseExponentialOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseExponentialOut::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseExponentialOut* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseExponentialOut*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseExponentialOut();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
void CCEaseExponentialOut::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->update(time == 1 ? 1 : (-powf(2, -10 * time / 1) + 1));
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCActionInterval* CCEaseExponentialOut::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseExponentialIn::actionWithAction(m_pOther->reverse());
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
//
|
|
|
|
// EaseExponentialInOut
|
|
|
|
//
|
|
|
|
CCEaseExponentialInOut* CCEaseExponentialInOut::actionWithAction(CCActionInterval *pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseExponentialInOut *pRet = new CCEaseExponentialInOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseExponentialInOut::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseExponentialInOut* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseExponentialInOut*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseExponentialInOut();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
void CCEaseExponentialInOut::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
time /= 0.5f;
|
|
|
|
if (time < 1)
|
|
|
|
{
|
|
|
|
time = 0.5f * powf(2, 10 * (time - 1));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
time = 0.5f * (-powf(2, 10 * (time - 1)) + 2);
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->update(time);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseSineIn
|
|
|
|
//
|
|
|
|
CCEaseSineIn* CCEaseSineIn::actionWithAction(CCActionInterval* pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseSineIn *pRet = new CCEaseSineIn();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCObject* CCEaseSineIn::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseSineIn* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseSineIn*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseSineIn();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCEaseSineIn::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->update(-1 * cosf(time * (float)M_PI_2) + 1);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCActionInterval* CCEaseSineIn::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseSineOut::actionWithAction(m_pOther->reverse());
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseSineOut
|
|
|
|
//
|
|
|
|
CCEaseSineOut* CCEaseSineOut::actionWithAction(CCActionInterval* pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseSineOut *pRet = new CCEaseSineOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseSineOut::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseSineOut* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseSineOut*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseSineOut();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
void CCEaseSineOut::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->update(sinf(time * (float)M_PI_2));
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCActionInterval* CCEaseSineOut::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseSineIn::actionWithAction(m_pOther->reverse());
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseSineInOut
|
|
|
|
//
|
|
|
|
CCEaseSineInOut* CCEaseSineInOut::actionWithAction(CCActionInterval* pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseSineInOut *pRet = new CCEaseSineInOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseSineInOut::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseSineInOut* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseSineInOut*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseSineInOut();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
void CCEaseSineInOut::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->update(-0.5f * (cosf((float)M_PI * time) - 1));
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
//
|
|
|
|
// EaseElastic
|
|
|
|
//
|
|
|
|
CCEaseElastic* CCEaseElastic::actionWithAction(CCActionInterval *pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseElastic *pRet = new CCEaseElastic();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCEaseElastic* CCEaseElastic::actionWithAction(CCActionInterval *pAction, float fPeriod)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseElastic *pRet = new CCEaseElastic();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction, fPeriod))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2012-04-19 10:46:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
bool CCEaseElastic::initWithAction(CCActionInterval *pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return initWithAction(pAction, 0.3f);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CCEaseElastic::initWithAction(CCActionInterval *pAction, float fPeriod)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
if (CCActionEase::initWithAction(pAction))
|
|
|
|
{
|
|
|
|
m_fPeriod = fPeriod;
|
|
|
|
return true;
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return false;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseElastic::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseElastic* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseElastic*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseElastic();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()), m_fPeriod);
|
2012-04-19 10:46:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCActionInterval* CCEaseElastic::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert(0, "");
|
2012-04-19 10:46:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return NULL;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseElasticIn
|
|
|
|
//
|
|
|
|
CCEaseElasticIn* CCEaseElasticIn::actionWithAction(CCActionInterval *pAction, float fPeriod)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseElasticIn *pRet = new CCEaseElasticIn();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction, fPeriod))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCEaseElasticIn* CCEaseElasticIn::actionWithAction(CCActionInterval *pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseElasticIn *pRet = new CCEaseElasticIn();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCObject* CCEaseElasticIn::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseElasticIn* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseElasticIn*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseElasticIn();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()), m_fPeriod);
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
void CCEaseElasticIn::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
ccTime newT = 0;
|
|
|
|
if (time == 0 || time == 1)
|
|
|
|
{
|
|
|
|
newT = time;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float s = m_fPeriod / 4;
|
|
|
|
time = time - 1;
|
|
|
|
newT = -powf(2, 10 * time) * sinf((time - s) * M_PI_X_2 / m_fPeriod);
|
|
|
|
}
|
2012-04-19 10:46:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->update(newT);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCActionInterval* CCEaseElasticIn::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseElasticOut::actionWithAction(m_pOther->reverse(), m_fPeriod);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseElasticOut
|
|
|
|
//
|
|
|
|
CCEaseElasticOut* CCEaseElasticOut::actionWithAction(CCActionInterval *pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseElasticOut *pRet = new CCEaseElasticOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCEaseElasticOut* CCEaseElasticOut::actionWithAction(CCActionInterval *pAction, float fPeriod)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseElasticOut *pRet = new CCEaseElasticOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction, fPeriod))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject *CCEaseElasticOut::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseElasticOut* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseElasticOut*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseElasticOut();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()), m_fPeriod);
|
2012-04-19 10:46:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
void CCEaseElasticOut::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
ccTime newT = 0;
|
|
|
|
if (time == 0 || time == 1)
|
|
|
|
{
|
|
|
|
newT = time;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float s = m_fPeriod / 4;
|
|
|
|
newT = powf(2, -10 * time) * sinf((time - s) * M_PI_X_2 / m_fPeriod) + 1;
|
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->update(newT);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCActionInterval* CCEaseElasticOut::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseElasticIn::actionWithAction(m_pOther->reverse(), m_fPeriod);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseElasticInOut
|
|
|
|
//
|
|
|
|
CCEaseElasticInOut* CCEaseElasticInOut::actionWithAction(CCActionInterval *pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseElasticInOut *pRet = new CCEaseElasticInOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCEaseElasticInOut* CCEaseElasticInOut::actionWithAction(CCActionInterval *pAction, float fPeriod)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseElasticInOut *pRet = new CCEaseElasticInOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction, fPeriod))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseElasticInOut::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseElasticInOut* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseElasticInOut*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseElasticInOut();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()), m_fPeriod);
|
2012-04-19 10:46:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCEaseElasticInOut::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
ccTime newT = 0;
|
|
|
|
if (time == 0 || time == 1)
|
|
|
|
{
|
|
|
|
newT = time;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
time = time * 2;
|
|
|
|
if (! m_fPeriod)
|
|
|
|
{
|
|
|
|
m_fPeriod = 0.3f * 1.5f;
|
|
|
|
}
|
|
|
|
|
|
|
|
ccTime s = m_fPeriod / 4;
|
|
|
|
|
|
|
|
time = time - 1;
|
|
|
|
if (time < 0)
|
|
|
|
{
|
|
|
|
newT = -0.5f * powf(2, 10 * time) * sinf((time -s) * M_PI_X_2 / m_fPeriod);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newT = powf(2, -10 * time) * sinf((time - s) * M_PI_X_2 / m_fPeriod) * 0.5f + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pOther->update(newT);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCActionInterval* CCEaseElasticInOut::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseInOut::actionWithAction(m_pOther->reverse(), m_fPeriod);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
//
|
|
|
|
// EaseBounce
|
|
|
|
//
|
|
|
|
CCEaseBounce* CCEaseBounce::actionWithAction(CCActionInterval* pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseBounce *pRet = new CCEaseBounce();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseBounce::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseBounce* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseBounce*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseBounce();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
ccTime CCEaseBounce::bounceTime(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
if (time < 1 / 2.75)
|
|
|
|
{
|
|
|
|
return 7.5625f * time * time;
|
|
|
|
} else
|
|
|
|
if (time < 2 / 2.75)
|
|
|
|
{
|
|
|
|
time -= 1.5f / 2.75f;
|
|
|
|
return 7.5625f * time * time + 0.75f;
|
|
|
|
} else
|
|
|
|
if(time < 2.5 / 2.75)
|
|
|
|
{
|
|
|
|
time -= 2.25f / 2.75f;
|
|
|
|
return 7.5625f * time * time + 0.9375f;
|
|
|
|
}
|
|
|
|
|
|
|
|
time -= 2.625f / 2.75f;
|
|
|
|
return 7.5625f * time * time + 0.984375f;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseBounceIn
|
|
|
|
//
|
|
|
|
CCEaseBounceIn* CCEaseBounceIn::actionWithAction(CCActionInterval* pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseBounceIn *pRet = new CCEaseBounceIn();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCObject* CCEaseBounceIn::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseBounceIn* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseBounceIn*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseBounceIn();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCEaseBounceIn::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
ccTime newT = 1 - bounceTime(1 - time);
|
|
|
|
m_pOther->update(newT);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCActionInterval* CCEaseBounceIn::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseBounceOut::actionWithAction(m_pOther->reverse());
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseBounceOut
|
|
|
|
//
|
|
|
|
CCEaseBounceOut* CCEaseBounceOut::actionWithAction(CCActionInterval* pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseBounceOut *pRet = new CCEaseBounceOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseBounceOut::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseBounceOut* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseBounceOut*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseBounceOut();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
void CCEaseBounceOut::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
ccTime newT = bounceTime(time);
|
|
|
|
m_pOther->update(newT);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCActionInterval* CCEaseBounceOut::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseBounceIn::actionWithAction(m_pOther->reverse());
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseBounceInOut
|
|
|
|
//
|
|
|
|
CCEaseBounceInOut* CCEaseBounceInOut::actionWithAction(CCActionInterval* pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseBounceInOut *pRet = new CCEaseBounceInOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseBounceInOut::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseBounceInOut* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseBounceInOut*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseBounceInOut();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
void CCEaseBounceInOut::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
ccTime newT = 0;
|
|
|
|
if (time < 0.5f)
|
|
|
|
{
|
|
|
|
time = time * 2;
|
|
|
|
newT = (1 - bounceTime(1 - time)) * 0.5f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newT = bounceTime(time * 2 - 1) * 0.5f + 0.5f;
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOther->update(newT);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseBackIn
|
|
|
|
//
|
|
|
|
CCEaseBackIn* CCEaseBackIn::actionWithAction(CCActionInterval *pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseBackIn *pRet = new CCEaseBackIn();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCObject* CCEaseBackIn::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseBackIn* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseBackIn*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseBackIn();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCEaseBackIn::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
ccTime overshoot = 1.70158f;
|
|
|
|
m_pOther->update(time * time * ((overshoot + 1) * time - overshoot));
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCActionInterval* CCEaseBackIn::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseBackOut::actionWithAction(m_pOther->reverse());
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseBackOut
|
|
|
|
//
|
|
|
|
CCEaseBackOut* CCEaseBackOut::actionWithAction(CCActionInterval* pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseBackOut *pRet = new CCEaseBackOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCEaseBackOut::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseBackOut* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseBackOut*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseBackOut();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
void CCEaseBackOut::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
ccTime overshoot = 1.70158f;
|
2012-04-19 10:46:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
time = time - 1;
|
|
|
|
m_pOther->update(time * time * ((overshoot + 1) * time + overshoot) + 1);
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCActionInterval* CCEaseBackOut::reverse(void)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCEaseBackIn::actionWithAction(m_pOther->reverse());
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EaseBackInOut
|
|
|
|
//
|
|
|
|
CCEaseBackInOut* CCEaseBackInOut::actionWithAction(CCActionInterval* pAction)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCEaseBackInOut *pRet = new CCEaseBackInOut();
|
|
|
|
if (pRet)
|
|
|
|
{
|
|
|
|
if (pRet->initWithAction(pAction))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(pRet);
|
|
|
|
}
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return pRet;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
CCObject* CCEaseBackInOut::copyWithZone(CCZone *pZone)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCZone* pNewZone = NULL;
|
|
|
|
CCEaseBackInOut* pCopy = NULL;
|
|
|
|
if(pZone && pZone->m_pCopyObject)
|
|
|
|
{
|
|
|
|
//in case of being called at sub class
|
|
|
|
pCopy = (CCEaseBackInOut*)(pZone->m_pCopyObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCopy = new CCEaseBackInOut();
|
|
|
|
pZone = pNewZone = new CCZone(pCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
pCopy->initWithAction((CCActionInterval *)(m_pOther->copy()->autorelease()));
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pNewZone);
|
|
|
|
return pCopy;
|
2012-04-19 10:46:37 +08:00
|
|
|
}
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2012-04-19 10:46:37 +08:00
|
|
|
void CCEaseBackInOut::update(ccTime time)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
ccTime overshoot = 1.70158f * 1.525f;
|
|
|
|
|
|
|
|
time = time * 2;
|
|
|
|
if (time < 1)
|
|
|
|
{
|
|
|
|
m_pOther->update((time * time * ((overshoot + 1) * time - overshoot)) / 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
time = time - 2;
|
|
|
|
m_pOther->update((time * time * ((overshoot + 1) * time + overshoot)) / 2 + 1);
|
|
|
|
}
|
2010-08-10 14:02:13 +08:00
|
|
|
}
|
2012-04-18 18:43:45 +08:00
|
|
|
|
|
|
|
NS_CC_END
|