axmol/cocos/2d/CCActionEase.cpp

1544 lines
30 KiB
C++
Raw Normal View History

2011-03-19 10:34:26 +08:00
/****************************************************************************
Copyright (c) 2008-2009 Jason Booth
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
2011-03-19 10:34:26 +08:00
http://www.cocos2d-x.org
2011-03-19 10:34:26 +08:00
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 "2d/CCActionEase.h"
#include "2d/CCTweenFunction.h"
2011-03-19 10:34:26 +08:00
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
//
// EaseAction
//
2013-11-16 21:08:00 +08:00
bool ActionEase::initWithAction(ActionInterval *action)
{
2013-11-16 21:08:00 +08:00
CCASSERT(action != nullptr, "");
2013-11-16 21:08:00 +08:00
if (ActionInterval::initWithDuration(action->getDuration()))
{
2013-11-16 21:08:00 +08:00
_inner = action;
action->retain();
2010-08-10 14:02:13 +08:00
return true;
}
2010-08-10 14:02:13 +08:00
return false;
}
2010-08-10 14:02:13 +08:00
ActionEase::~ActionEase(void)
{
CC_SAFE_RELEASE(_inner);
}
void ActionEase::startWithTarget(Node *target)
{
ActionInterval::startWithTarget(target);
_inner->startWithTarget(_target);
}
void ActionEase::stop(void)
{
_inner->stop();
ActionInterval::stop();
}
void ActionEase::update(float time)
{
_inner->update(time);
}
2010-08-10 14:02:13 +08:00
ActionInterval* ActionEase::getInnerAction()
{
return _inner;
}
//
// EaseRateAction
//
2013-11-16 21:08:00 +08:00
bool EaseRateAction::initWithAction(ActionInterval *action, float rate)
{
2013-11-16 21:08:00 +08:00
if (ActionEase::initWithAction(action))
{
2013-11-16 21:08:00 +08:00
_rate = rate;
return true;
}
2010-08-10 14:02:13 +08:00
return false;
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
EaseRateAction::~EaseRateAction()
{
}
2010-08-10 14:02:13 +08:00
//
// EeseIn
//
2013-11-16 21:08:00 +08:00
EaseIn* EaseIn::create(ActionInterval *action, float rate)
{
EaseIn *easeIn = new (std::nothrow) EaseIn();
2013-11-16 21:08:00 +08:00
if (easeIn)
{
2013-11-16 21:08:00 +08:00
if (easeIn->initWithAction(action, rate))
{
2013-11-16 21:08:00 +08:00
easeIn->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(easeIn);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return easeIn;
}
EaseIn* EaseIn::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseIn();
a->initWithAction(_inner->clone(), _rate);
a->autorelease();
return a;
}
void EaseIn::update(float time)
{
_inner->update(tweenfunc::easeIn(time, _rate));
}
2010-08-25 18:31:55 +08:00
EaseIn* EaseIn::reverse() const
{
return EaseIn::create(_inner->reverse(), 1 / _rate);
}
//
// EaseOut
//
2013-11-16 21:08:00 +08:00
EaseOut* EaseOut::create(ActionInterval *action, float rate)
{
EaseOut *easeOut = new (std::nothrow) EaseOut();
2013-11-16 21:08:00 +08:00
if (easeOut)
{
2013-11-16 21:08:00 +08:00
if (easeOut->initWithAction(action, rate))
{
2013-11-16 21:08:00 +08:00
easeOut->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(easeOut);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return easeOut;
}
2010-08-10 14:02:13 +08:00
EaseOut* EaseOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseOut();
a->initWithAction(_inner->clone(), _rate);
a->autorelease();
return a;
}
void EaseOut::update(float time)
{
_inner->update(tweenfunc::easeOut(time, _rate));
}
2010-08-25 18:31:55 +08:00
EaseOut* EaseOut::reverse() const
{
return EaseOut::create(_inner->reverse(), 1 / _rate);
}
//
// EaseInOut
//
2013-11-16 21:08:00 +08:00
EaseInOut* EaseInOut::create(ActionInterval *action, float rate)
{
EaseInOut *easeInOut = new (std::nothrow) EaseInOut();
2013-11-16 21:08:00 +08:00
if (easeInOut)
{
2013-11-16 21:08:00 +08:00
if (easeInOut->initWithAction(action, rate))
{
2013-11-16 21:08:00 +08:00
easeInOut->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(easeInOut);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return easeInOut;
}
EaseInOut* EaseInOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseInOut();
a->initWithAction(_inner->clone(), _rate);
a->autorelease();
return a;
}
void EaseInOut::update(float time)
{
_inner->update(tweenfunc::easeInOut(time, _rate));
}
2010-08-10 14:02:13 +08:00
// InOut and OutIn are symmetrical
EaseInOut* EaseInOut::reverse() const
{
return EaseInOut::create(_inner->reverse(), _rate);
}
2010-08-10 14:02:13 +08:00
//
// EaseExponentialIn
//
2013-11-16 21:08:00 +08:00
EaseExponentialIn* EaseExponentialIn::create(ActionInterval* action)
{
EaseExponentialIn *ret = new (std::nothrow) EaseExponentialIn();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
EaseExponentialIn* EaseExponentialIn::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseExponentialIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseExponentialIn::update(float time)
{
_inner->update(tweenfunc::expoEaseIn(time));
}
ActionEase * EaseExponentialIn::reverse() const
{
return EaseExponentialOut::create(_inner->reverse());
}
//
// EaseExponentialOut
//
2013-11-16 21:08:00 +08:00
EaseExponentialOut* EaseExponentialOut::create(ActionInterval* action)
{
EaseExponentialOut *ret = new (std::nothrow) EaseExponentialOut();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
EaseExponentialOut* EaseExponentialOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseExponentialOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseExponentialOut::update(float time)
{
_inner->update(tweenfunc::expoEaseOut(time));
}
ActionEase* EaseExponentialOut::reverse() const
{
return EaseExponentialIn::create(_inner->reverse());
}
2010-08-25 18:31:55 +08:00
//
// EaseExponentialInOut
//
2013-11-16 21:08:00 +08:00
EaseExponentialInOut* EaseExponentialInOut::create(ActionInterval *action)
{
EaseExponentialInOut *ret = new (std::nothrow) EaseExponentialInOut();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
EaseExponentialInOut* EaseExponentialInOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseExponentialInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseExponentialInOut::update(float time)
{
_inner->update(tweenfunc::expoEaseInOut(time));
}
EaseExponentialInOut* EaseExponentialInOut::reverse() const
{
return EaseExponentialInOut::create(_inner->reverse());
}
//
// EaseSineIn
//
2013-11-16 21:08:00 +08:00
EaseSineIn* EaseSineIn::create(ActionInterval* action)
{
EaseSineIn *ret = new (std::nothrow) EaseSineIn();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
2010-08-25 18:31:55 +08:00
EaseSineIn* EaseSineIn::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseSineIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseSineIn::update(float time)
{
_inner->update(tweenfunc::sineEaseIn(time));
}
ActionEase* EaseSineIn::reverse() const
{
return EaseSineOut::create(_inner->reverse());
}
//
// EaseSineOut
//
2013-11-16 21:08:00 +08:00
EaseSineOut* EaseSineOut::create(ActionInterval* action)
{
EaseSineOut *ret = new (std::nothrow) EaseSineOut();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
EaseSineOut* EaseSineOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseSineOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseSineOut::update(float time)
{
_inner->update(tweenfunc::sineEaseOut(time));
}
2010-08-25 18:31:55 +08:00
ActionEase* EaseSineOut::reverse(void) const
{
return EaseSineIn::create(_inner->reverse());
}
//
// EaseSineInOut
//
2013-11-16 21:08:00 +08:00
EaseSineInOut* EaseSineInOut::create(ActionInterval* action)
{
EaseSineInOut *ret = new (std::nothrow) EaseSineInOut();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
EaseSineInOut* EaseSineInOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseSineInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseSineInOut::update(float time)
{
_inner->update(tweenfunc::sineEaseInOut(time));
}
2010-08-25 18:31:55 +08:00
EaseSineInOut* EaseSineInOut::reverse() const
{
return EaseSineInOut::create(_inner->reverse());
}
//
// EaseElastic
//
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
bool EaseElastic::initWithAction(ActionInterval *action, float period/* = 0.3f*/)
{
2013-11-16 21:08:00 +08:00
if (ActionEase::initWithAction(action))
{
2013-11-16 21:08:00 +08:00
_period = period;
return true;
}
2010-08-10 14:02:13 +08:00
return false;
}
//
// EaseElasticIn
//
2013-11-16 21:08:00 +08:00
EaseElasticIn* EaseElasticIn::create(ActionInterval *action)
{
2013-11-16 21:08:00 +08:00
return EaseElasticIn::create(action, 0.3f);
}
2013-11-16 21:08:00 +08:00
EaseElasticIn* EaseElasticIn::create(ActionInterval *action, float period/* = 0.3f*/)
{
EaseElasticIn *ret = new (std::nothrow) EaseElasticIn();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action, period))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
EaseElasticIn* EaseElasticIn::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseElasticIn();
a->initWithAction(_inner->clone(), _period);
a->autorelease();
return a;
}
void EaseElasticIn::update(float time)
{
2014-03-08 21:48:44 +08:00
_inner->update(tweenfunc::elasticEaseIn(time, _period));
}
2010-08-25 18:31:55 +08:00
EaseElastic* EaseElasticIn::reverse() const
{
return EaseElasticOut::create(_inner->reverse(), _period);
}
//
// EaseElasticOut
//
2013-11-16 21:08:00 +08:00
EaseElasticOut* EaseElasticOut::create(ActionInterval *action)
{
2013-11-16 21:08:00 +08:00
return EaseElasticOut::create(action, 0.3f);
}
2013-11-16 21:08:00 +08:00
EaseElasticOut* EaseElasticOut::create(ActionInterval *action, float period/* = 0.3f*/)
{
EaseElasticOut *ret = new (std::nothrow) EaseElasticOut();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action, period))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
EaseElasticOut* EaseElasticOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseElasticOut();
a->initWithAction(_inner->clone(), _period);
a->autorelease();
return a;
}
void EaseElasticOut::update(float time)
{
2014-03-08 21:48:44 +08:00
_inner->update(tweenfunc::elasticEaseOut(time, _period));
}
EaseElastic* EaseElasticOut::reverse() const
{
return EaseElasticIn::create(_inner->reverse(), _period);
}
//
// EaseElasticInOut
//
2013-11-16 21:08:00 +08:00
EaseElasticInOut* EaseElasticInOut::create(ActionInterval *action)
{
2013-11-16 21:08:00 +08:00
return EaseElasticInOut::create(action, 0.3f);
}
2013-11-16 21:08:00 +08:00
EaseElasticInOut* EaseElasticInOut::create(ActionInterval *action, float period/* = 0.3f*/)
{
EaseElasticInOut *ret = new (std::nothrow) EaseElasticInOut();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action, period))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
EaseElasticInOut* EaseElasticInOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseElasticInOut();
a->initWithAction(_inner->clone(), _period);
a->autorelease();
return a;
}
void EaseElasticInOut::update(float time)
{
2014-03-08 21:48:44 +08:00
_inner->update(tweenfunc::elasticEaseInOut(time, _period));
}
2010-08-10 14:02:13 +08:00
EaseElasticInOut* EaseElasticInOut::reverse() const
{
return EaseElasticInOut::create(_inner->reverse(), _period);
}
2010-08-10 14:02:13 +08:00
//
// EaseBounce
//
//
// EaseBounceIn
//
2013-11-16 21:08:00 +08:00
EaseBounceIn* EaseBounceIn::create(ActionInterval* action)
{
EaseBounceIn *ret = new (std::nothrow) EaseBounceIn();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
2010-08-10 14:02:13 +08:00
EaseBounceIn* EaseBounceIn::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseBounceIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseBounceIn::update(float time)
{
_inner->update(tweenfunc::bounceEaseIn(time));
}
EaseBounce* EaseBounceIn::reverse() const
{
return EaseBounceOut::create(_inner->reverse());
}
//
// EaseBounceOut
//
2013-11-16 21:08:00 +08:00
EaseBounceOut* EaseBounceOut::create(ActionInterval* action)
{
EaseBounceOut *ret = new (std::nothrow) EaseBounceOut();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
EaseBounceOut* EaseBounceOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseBounceOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseBounceOut::update(float time)
{
_inner->update(tweenfunc::bounceEaseOut(time));
}
2010-08-25 18:31:55 +08:00
EaseBounce* EaseBounceOut::reverse() const
{
return EaseBounceIn::create(_inner->reverse());
}
//
// EaseBounceInOut
//
2013-11-16 21:08:00 +08:00
EaseBounceInOut* EaseBounceInOut::create(ActionInterval* action)
{
EaseBounceInOut *ret = new (std::nothrow) EaseBounceInOut();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
EaseBounceInOut* EaseBounceInOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseBounceInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseBounceInOut::update(float time)
{
_inner->update(tweenfunc::bounceEaseInOut(time));
}
EaseBounceInOut* EaseBounceInOut::reverse() const
{
return EaseBounceInOut::create(_inner->reverse());
}
//
// EaseBackIn
//
2013-11-16 21:08:00 +08:00
EaseBackIn* EaseBackIn::create(ActionInterval *action)
{
EaseBackIn *ret = new (std::nothrow) EaseBackIn();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
2010-08-25 18:31:55 +08:00
EaseBackIn* EaseBackIn::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseBackIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseBackIn::update(float time)
{
_inner->update(tweenfunc::backEaseIn(time));
}
ActionEase* EaseBackIn::reverse() const
{
return EaseBackOut::create(_inner->reverse());
}
//
// EaseBackOut
//
2013-11-16 21:08:00 +08:00
EaseBackOut* EaseBackOut::create(ActionInterval* action)
{
EaseBackOut *ret = new (std::nothrow) EaseBackOut();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
EaseBackOut* EaseBackOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseBackOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseBackOut::update(float time)
{
_inner->update(tweenfunc::backEaseOut(time));
}
2010-08-25 18:31:55 +08:00
ActionEase* EaseBackOut::reverse() const
{
return EaseBackIn::create(_inner->reverse());
}
//
// EaseBackInOut
//
2013-11-16 21:08:00 +08:00
EaseBackInOut* EaseBackInOut::create(ActionInterval* action)
{
EaseBackInOut *ret = new (std::nothrow) EaseBackInOut();
2013-11-16 21:08:00 +08:00
if (ret)
{
2013-11-16 21:08:00 +08:00
if (ret->initWithAction(action))
{
2013-11-16 21:08:00 +08:00
ret->autorelease();
}
else
{
2013-11-16 21:08:00 +08:00
CC_SAFE_RELEASE_NULL(ret);
}
}
2010-08-10 14:02:13 +08:00
2013-11-16 21:08:00 +08:00
return ret;
}
2010-08-10 14:02:13 +08:00
EaseBackInOut* EaseBackInOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseBackInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseBackInOut::update(float time)
{
_inner->update(tweenfunc::backEaseInOut(time));
2010-08-10 14:02:13 +08:00
}
2012-04-18 18:43:45 +08:00
EaseBackInOut* EaseBackInOut::reverse() const
{
return EaseBackInOut::create(_inner->reverse());
}
EaseBezierAction* EaseBezierAction::create(cocos2d::ActionInterval* action)
{
EaseBezierAction *ret = new (std::nothrow) EaseBezierAction();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
void EaseBezierAction::setBezierParamer( float p0, float p1, float p2, float p3)
{
_p0 = p0;
_p1 = p1;
_p2 = p2;
_p3 = p3;
}
EaseBezierAction* EaseBezierAction::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseBezierAction();
a->initWithAction(_inner->clone());
a->setBezierParamer(_p0,_p1,_p2,_p3);
a->autorelease();
return a;
}
void EaseBezierAction::update(float time)
{
_inner->update(tweenfunc::bezieratFunction(_p0,_p1,_p2,_p3,time));
}
EaseBezierAction* EaseBezierAction::reverse() const
{
EaseBezierAction* reverseAction = EaseBezierAction::create(_inner->reverse());
reverseAction->setBezierParamer(_p3,_p2,_p1,_p0);
return reverseAction;
}
//
// EaseQuadraticActionIn
//
EaseQuadraticActionIn* EaseQuadraticActionIn::create(ActionInterval* action)
{
EaseQuadraticActionIn *ret = new (std::nothrow) EaseQuadraticActionIn();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseQuadraticActionIn* EaseQuadraticActionIn::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseQuadraticActionIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseQuadraticActionIn::update(float time)
{
_inner->update(tweenfunc::quadraticIn(time));
}
EaseQuadraticActionIn* EaseQuadraticActionIn::reverse() const
{
return EaseQuadraticActionIn::create(_inner->reverse());
}
//
// EaseQuadraticActionOut
//
EaseQuadraticActionOut* EaseQuadraticActionOut::create(ActionInterval* action)
{
EaseQuadraticActionOut *ret = new (std::nothrow) EaseQuadraticActionOut();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseQuadraticActionOut* EaseQuadraticActionOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseQuadraticActionOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseQuadraticActionOut::update(float time)
{
_inner->update(tweenfunc::quadraticOut(time));
}
EaseQuadraticActionOut* EaseQuadraticActionOut::reverse() const
{
return EaseQuadraticActionOut::create(_inner->reverse());
}
//
// EaseQuadraticActionInOut
//
EaseQuadraticActionInOut* EaseQuadraticActionInOut::create(ActionInterval* action)
{
EaseQuadraticActionInOut *ret = new (std::nothrow) EaseQuadraticActionInOut();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseQuadraticActionInOut* EaseQuadraticActionInOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseQuadraticActionInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseQuadraticActionInOut::update(float time)
{
_inner->update(tweenfunc::quadraticInOut(time));
}
EaseQuadraticActionInOut* EaseQuadraticActionInOut::reverse() const
{
return EaseQuadraticActionInOut::create(_inner->reverse());
}
//
// EaseQuarticActionIn
//
EaseQuarticActionIn* EaseQuarticActionIn::create(ActionInterval* action)
{
EaseQuarticActionIn *ret = new (std::nothrow) EaseQuarticActionIn();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseQuarticActionIn* EaseQuarticActionIn::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseQuarticActionIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseQuarticActionIn::update(float time)
{
_inner->update(tweenfunc::quartEaseIn(time));
}
EaseQuarticActionIn* EaseQuarticActionIn::reverse() const
{
return EaseQuarticActionIn::create(_inner->reverse());
}
//
// EaseQuarticActionOut
//
EaseQuarticActionOut* EaseQuarticActionOut::create(ActionInterval* action)
{
EaseQuarticActionOut *ret = new (std::nothrow) EaseQuarticActionOut();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseQuarticActionOut* EaseQuarticActionOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseQuarticActionOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseQuarticActionOut::update(float time)
{
_inner->update(tweenfunc::quartEaseOut(time));
}
EaseQuarticActionOut* EaseQuarticActionOut::reverse() const
{
return EaseQuarticActionOut::create(_inner->reverse());
}
//
// EaseQuarticActionInOut
//
EaseQuarticActionInOut* EaseQuarticActionInOut::create(ActionInterval* action)
{
EaseQuarticActionInOut *ret = new (std::nothrow) EaseQuarticActionInOut();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseQuarticActionInOut* EaseQuarticActionInOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseQuarticActionInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseQuarticActionInOut::update(float time)
{
_inner->update(tweenfunc::quartEaseInOut(time));
}
EaseQuarticActionInOut* EaseQuarticActionInOut::reverse() const
{
return EaseQuarticActionInOut::create(_inner->reverse());
}
//
// EaseQuinticActionIn
//
EaseQuinticActionIn* EaseQuinticActionIn::create(ActionInterval* action)
{
EaseQuinticActionIn *ret = new (std::nothrow) EaseQuinticActionIn();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseQuinticActionIn* EaseQuinticActionIn::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseQuinticActionIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseQuinticActionIn::update(float time)
{
_inner->update(tweenfunc::quintEaseIn(time));
}
EaseQuinticActionIn* EaseQuinticActionIn::reverse() const
{
return EaseQuinticActionIn::create(_inner->reverse());
}
//
// EaseQuinticActionOut
//
EaseQuinticActionOut* EaseQuinticActionOut::create(ActionInterval* action)
{
EaseQuinticActionOut *ret = new (std::nothrow) EaseQuinticActionOut();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseQuinticActionOut* EaseQuinticActionOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseQuinticActionOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseQuinticActionOut::update(float time)
{
_inner->update(tweenfunc::quintEaseOut(time));
}
EaseQuinticActionOut* EaseQuinticActionOut::reverse() const
{
return EaseQuinticActionOut::create(_inner->reverse());
}
//
// EaseQuinticActionInOut
//
EaseQuinticActionInOut* EaseQuinticActionInOut::create(ActionInterval* action)
{
EaseQuinticActionInOut *ret = new (std::nothrow) EaseQuinticActionInOut();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseQuinticActionInOut* EaseQuinticActionInOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseQuinticActionInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseQuinticActionInOut::update(float time)
{
_inner->update(tweenfunc::quintEaseInOut(time));
}
EaseQuinticActionInOut* EaseQuinticActionInOut::reverse() const
{
return EaseQuinticActionInOut::create(_inner->reverse());
}
//
// EaseCircleActionIn
//
EaseCircleActionIn* EaseCircleActionIn::create(ActionInterval* action)
{
EaseCircleActionIn *ret = new (std::nothrow) EaseCircleActionIn();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseCircleActionIn* EaseCircleActionIn::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseCircleActionIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseCircleActionIn::update(float time)
{
_inner->update(tweenfunc::circEaseIn(time));
}
EaseCircleActionIn* EaseCircleActionIn::reverse() const
{
return EaseCircleActionIn::create(_inner->reverse());
}
//
// EaseCircleActionOut
//
EaseCircleActionOut* EaseCircleActionOut::create(ActionInterval* action)
{
EaseCircleActionOut *ret = new (std::nothrow) EaseCircleActionOut();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseCircleActionOut* EaseCircleActionOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseCircleActionOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseCircleActionOut::update(float time)
{
_inner->update(tweenfunc::circEaseOut(time));
}
EaseCircleActionOut* EaseCircleActionOut::reverse() const
{
return EaseCircleActionOut::create(_inner->reverse());
}
//
// EaseCircleActionInOut
//
EaseCircleActionInOut* EaseCircleActionInOut::create(ActionInterval* action)
{
EaseCircleActionInOut *ret = new (std::nothrow) EaseCircleActionInOut();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseCircleActionInOut* EaseCircleActionInOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseCircleActionInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseCircleActionInOut::update(float time)
{
_inner->update(tweenfunc::circEaseInOut(time));
}
EaseCircleActionInOut* EaseCircleActionInOut::reverse() const
{
return EaseCircleActionInOut::create(_inner->reverse());
}
//
// EaseCubicActionIn
//
EaseCubicActionIn* EaseCubicActionIn::create(ActionInterval* action)
{
EaseCubicActionIn *ret = new (std::nothrow) EaseCubicActionIn();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseCubicActionIn* EaseCubicActionIn::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseCubicActionIn();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseCubicActionIn::update(float time)
{
_inner->update(tweenfunc::cubicEaseIn(time));
}
EaseCubicActionIn* EaseCubicActionIn::reverse() const
{
return EaseCubicActionIn::create(_inner->reverse());
}
//
// EaseCubicActionOut
//
EaseCubicActionOut* EaseCubicActionOut::create(ActionInterval* action)
{
EaseCubicActionOut *ret = new (std::nothrow) EaseCubicActionOut();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseCubicActionOut* EaseCubicActionOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseCubicActionOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseCubicActionOut::update(float time)
{
_inner->update(tweenfunc::cubicEaseOut(time));
}
EaseCubicActionOut* EaseCubicActionOut::reverse() const
{
return EaseCubicActionOut::create(_inner->reverse());
}
//
// EaseCubicActionInOut
//
EaseCubicActionInOut* EaseCubicActionInOut::create(ActionInterval* action)
{
EaseCubicActionInOut *ret = new (std::nothrow) EaseCubicActionInOut();
if (ret)
{
if (ret->initWithAction(action))
{
ret->autorelease();
}
else
{
CC_SAFE_RELEASE_NULL(ret);
}
}
return ret;
}
EaseCubicActionInOut* EaseCubicActionInOut::clone() const
{
// no copy constructor
auto a = new (std::nothrow) EaseCubicActionInOut();
a->initWithAction(_inner->clone());
a->autorelease();
return a;
}
void EaseCubicActionInOut::update(float time)
{
_inner->update(tweenfunc::cubicEaseInOut(time));
}
EaseCubicActionInOut* EaseCubicActionInOut::reverse() const
{
return EaseCubicActionInOut::create(_inner->reverse());
}
2012-04-18 18:43:45 +08:00
NS_CC_END