2011-03-19 10:59:01 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2008-2009 Jason Booth
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2017-02-14 14:36:57 +08:00
|
|
|
Copyright (c) 2013-2017 Chukong Technologies Inc.
|
2011-03-19 10:59:01 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __ACTION_CCEASE_ACTION_H__
|
|
|
|
#define __ACTION_CCEASE_ACTION_H__
|
|
|
|
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "2d/CCActionInterval.h"
|
2016-09-05 10:18:30 +08:00
|
|
|
#include "2d/CCTweenFunction.h"
|
2011-03-19 10:59:01 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_BEGIN
|
2011-03-19 10:59:01 +08:00
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup actions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
2015-03-18 18:15:34 +08:00
|
|
|
@class ActionEase
|
|
|
|
@brief Base class for Easing actions.
|
2015-03-19 15:59:58 +08:00
|
|
|
@details Ease actions are created from other interval actions.
|
2016-09-05 10:18:30 +08:00
|
|
|
The ease action will change the timeline of the inner action.
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL ActionEase : public ActionInterval
|
2010-08-10 14:02:13 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-18 18:15:34 +08:00
|
|
|
/**
|
2016-09-05 10:18:30 +08:00
|
|
|
@brief Get the pointer of the inner action.
|
|
|
|
@return The pointer of the inner action.
|
2015-03-18 18:15:34 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual ActionInterval* getInnerAction();
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2013-07-16 03:43:22 +08:00
|
|
|
//
|
|
|
|
// Overrides
|
|
|
|
//
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual void startWithTarget(Node *target) override;
|
2013-11-16 21:08:00 +08:00
|
|
|
virtual void stop() override;
|
2013-07-16 03:43:22 +08:00
|
|
|
virtual void update(float time) override;
|
|
|
|
|
2014-03-28 17:45:06 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2016-04-08 13:40:36 +08:00
|
|
|
ActionEase()
|
|
|
|
: _inner(nullptr)
|
|
|
|
{}
|
|
|
|
|
2013-11-22 09:06:06 +08:00
|
|
|
virtual ~ActionEase();
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
2015-03-18 18:15:34 +08:00
|
|
|
@brief Initializes the action.
|
|
|
|
@return Return true when the initialization success, otherwise return false.
|
|
|
|
*/
|
2013-11-22 09:06:06 +08:00
|
|
|
bool initWithAction(ActionInterval *action);
|
|
|
|
|
2014-03-28 17:45:06 +08:00
|
|
|
protected:
|
2012-12-26 18:59:31 +08:00
|
|
|
/** The inner action */
|
2013-06-20 14:13:12 +08:00
|
|
|
ActionInterval *_inner;
|
2013-11-22 09:06:06 +08:00
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(ActionEase);
|
2010-08-10 14:02:13 +08:00
|
|
|
};
|
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
2015-03-18 18:15:34 +08:00
|
|
|
@class EaseRateAction
|
2016-09-05 10:18:30 +08:00
|
|
|
@brief Base class for Easing actions with rate parameters
|
2015-03-19 15:59:58 +08:00
|
|
|
@details Ease the inner action with specified rate.
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL EaseRateAction : public ActionEase
|
2010-08-10 14:02:13 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-24 18:31:44 +08:00
|
|
|
static EaseRateAction* create(ActionInterval* action, float rate);
|
2015-03-18 18:15:34 +08:00
|
|
|
/**
|
2016-09-05 10:18:30 +08:00
|
|
|
@brief Set the rate value for the ease rate action.
|
|
|
|
@param rate The value will be set.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setRate(float rate) { _rate = rate; }
|
2015-03-18 18:15:34 +08:00
|
|
|
/**
|
2016-09-05 10:18:30 +08:00
|
|
|
@brief Get the rate value of the ease rate action.
|
|
|
|
@return Return the rate value of the ease rate action.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getRate() const { return _rate; }
|
2010-09-28 16:18:05 +08:00
|
|
|
|
2014-03-28 17:45:06 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-22 09:06:06 +08:00
|
|
|
EaseRateAction() {}
|
2016-09-05 10:18:30 +08:00
|
|
|
virtual ~EaseRateAction() {}
|
|
|
|
/**
|
2015-03-18 18:15:34 +08:00
|
|
|
@brief Initializes the action with the inner action and the rate parameter.
|
|
|
|
@param pAction The pointer of the inner action.
|
|
|
|
@param fRate The value of the rate parameter.
|
|
|
|
@return Return true when the initialization success, otherwise return false.
|
2016-09-05 10:18:30 +08:00
|
|
|
*/
|
2013-11-22 09:06:06 +08:00
|
|
|
bool initWithAction(ActionInterval *pAction, float fRate);
|
|
|
|
|
2014-03-28 17:45:06 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
float _rate;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(EaseRateAction);
|
2010-08-10 14:02:13 +08:00
|
|
|
};
|
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
//
|
|
|
|
// NOTE: Converting these macros into Templates is desirable, but please see
|
|
|
|
// issue #16159 [https://github.com/cocos2d/cocos2d-x/pull/16159] for further info
|
|
|
|
//
|
|
|
|
#define EASE_TEMPLATE_DECL_CLASS(CLASSNAME) \
|
|
|
|
class CC_DLL CLASSNAME : public ActionEase \
|
|
|
|
{ \
|
|
|
|
CC_CONSTRUCTOR_ACCESS: \
|
|
|
|
virtual ~CLASSNAME() { } \
|
|
|
|
CLASSNAME() { } \
|
|
|
|
public: \
|
|
|
|
static CLASSNAME* create(ActionInterval* action); \
|
2016-10-26 15:54:01 +08:00
|
|
|
virtual CLASSNAME* clone() const override; \
|
|
|
|
virtual void update(float time) override; \
|
|
|
|
virtual ActionEase* reverse() const override; \
|
2016-09-05 10:18:30 +08:00
|
|
|
private: \
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(CLASSNAME); \
|
2010-08-10 14:02:13 +08:00
|
|
|
};
|
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
2015-03-18 18:15:34 +08:00
|
|
|
@class EaseExponentialIn
|
|
|
|
@brief Ease Exponential In action.
|
2015-03-19 15:59:58 +08:00
|
|
|
@details The timeline of inner action will be changed by:
|
2016-09-05 10:18:30 +08:00
|
|
|
\f${ 2 }^{ 10*(time-1) }-1*0.001\f$.
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseExponentialIn);
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
2015-03-18 18:15:34 +08:00
|
|
|
@class EaseExponentialOut
|
2010-09-28 18:27:33 +08:00
|
|
|
@brief Ease Exponential Out
|
2015-03-19 15:59:58 +08:00
|
|
|
@details The timeline of inner action will be changed by:
|
2016-09-05 10:18:30 +08:00
|
|
|
\f$1-{ 2 }^{ -10*(time-1) }\f$.
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseExponentialOut);
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
2015-03-18 18:15:34 +08:00
|
|
|
@class EaseExponentialInOut
|
2010-09-28 18:27:33 +08:00
|
|
|
@brief Ease Exponential InOut
|
2015-03-19 15:59:58 +08:00
|
|
|
@details If time * 2 < 1, the timeline of inner action will be changed by:
|
2016-09-05 10:18:30 +08:00
|
|
|
\f$0.5*{ 2 }^{ 10*(time-1) }\f$.
|
|
|
|
else, the timeline of inner action will be changed by:
|
|
|
|
\f$0.5*(2-{ 2 }^{ -10*(time-1) })\f$.
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseExponentialInOut);
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
2015-03-18 18:15:34 +08:00
|
|
|
@class EaseSineIn
|
2010-09-28 18:27:33 +08:00
|
|
|
@brief Ease Sine In
|
2015-03-19 15:59:58 +08:00
|
|
|
@details The timeline of inner action will be changed by:
|
2016-09-05 10:18:30 +08:00
|
|
|
\f$1-cos(time*\frac { \pi }{ 2 } )\f$.
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseSineIn);
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
2015-03-18 18:15:34 +08:00
|
|
|
@class EaseSineOut
|
2010-09-28 18:27:33 +08:00
|
|
|
@brief Ease Sine Out
|
2015-03-19 15:59:58 +08:00
|
|
|
@details The timeline of inner action will be changed by:
|
2016-09-05 10:18:30 +08:00
|
|
|
\f$sin(time*\frac { \pi }{ 2 } )\f$.
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseSineOut);
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
2015-03-18 18:15:34 +08:00
|
|
|
@class EaseSineInOut
|
2010-09-28 18:27:33 +08:00
|
|
|
@brief Ease Sine InOut
|
2015-03-19 15:59:58 +08:00
|
|
|
@details The timeline of inner action will be changed by:
|
2016-09-05 10:18:30 +08:00
|
|
|
\f$-0.5*(cos(\pi *time)-1)\f$.
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseSineInOut);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2016-09-12 09:51:27 +08:00
|
|
|
/**
|
|
|
|
@class EaseBounce
|
|
|
|
@brief EaseBounce abstract class.
|
|
|
|
@since v0.8.2
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
class CC_DLL EaseBounce : public ActionEase {};
|
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseBounceIn
|
|
|
|
@brief EaseBounceIn action.
|
|
|
|
@warning This action doesn't use a bijective function.
|
|
|
|
Actions like Sequence might have an unexpected result when used with this action.
|
2010-08-10 14:02:13 +08:00
|
|
|
@since v0.8.2
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseBounceIn);
|
2015-03-18 18:15:34 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseBounceOut
|
|
|
|
@brief EaseBounceOut action.
|
2015-03-18 18:15:34 +08:00
|
|
|
@warning This action doesn't use a bijective function.
|
2016-09-05 10:18:30 +08:00
|
|
|
Actions like Sequence might have an unexpected result when used with this action.
|
2010-08-10 14:02:13 +08:00
|
|
|
@since v0.8.2
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseBounceOut);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseBounceInOut
|
|
|
|
@brief EaseBounceInOut action.
|
2015-03-18 18:15:34 +08:00
|
|
|
@warning This action doesn't use a bijective function.
|
2016-09-05 10:18:30 +08:00
|
|
|
Actions like Sequence might have an unexpected result when used with this action.
|
2010-08-10 14:02:13 +08:00
|
|
|
@since v0.8.2
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseBounceInOut);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseBackIn
|
|
|
|
@brief EaseBackIn action.
|
2015-03-18 18:15:34 +08:00
|
|
|
@warning This action doesn't use a bijective function.
|
2016-09-05 10:18:30 +08:00
|
|
|
Actions like Sequence might have an unexpected result when used with this action.
|
2010-08-10 14:02:13 +08:00
|
|
|
@since v0.8.2
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseBackIn);
|
2015-03-18 18:15:34 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseBackOut
|
|
|
|
@brief EaseBackOut action.
|
|
|
|
@warning This action doesn't use a bijective function.
|
|
|
|
Actions like Sequence might have an unexpected result when used with this action.
|
|
|
|
@since v0.8.2
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseBackOut);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseBackInOut
|
|
|
|
@brief EaseBackInOut action.
|
|
|
|
@warning This action doesn't use a bijective function.
|
|
|
|
Actions like Sequence might have an unexpected result when used with this action.
|
2010-08-10 14:02:13 +08:00
|
|
|
@since v0.8.2
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2016-09-05 10:18:30 +08:00
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseBackInOut);
|
2010-08-25 18:31:55 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseQuadraticActionIn
|
|
|
|
@brief Ease Quadratic In
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseQuadraticActionIn);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseQuadraticActionOut
|
|
|
|
@brief Ease Quadratic Out
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseQuadraticActionOut);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseQuadraticActionInOut
|
|
|
|
@brief Ease Quadratic InOut
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseQuadraticActionInOut);
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseQuarticActionIn
|
|
|
|
@brief Ease Quartic In
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2016-09-05 10:18:30 +08:00
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseQuarticActionIn);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseQuarticActionOut
|
|
|
|
@brief Ease Quartic Out
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseQuarticActionOut);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseQuarticActionInOut
|
|
|
|
@brief Ease Quartic InOut
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseQuarticActionInOut);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseQuinticActionIn
|
|
|
|
@brief Ease Quintic In
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseQuinticActionIn);
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseQuinticActionOut
|
|
|
|
@brief Ease Quintic Out
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseQuinticActionOut);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseQuinticActionInOut
|
|
|
|
@brief Ease Quintic InOut
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseQuinticActionInOut);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseCircleActionIn
|
|
|
|
@brief Ease Circle In
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseCircleActionIn);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseCircleActionOut
|
|
|
|
@brief Ease Circle Out
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseCircleActionOut);
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseCircleActionInOut
|
|
|
|
@brief Ease Circle InOut
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseCircleActionInOut);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseCubicActionIn
|
|
|
|
@brief Ease Cubic In
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseCubicActionIn);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseCubicActionOut
|
|
|
|
@brief Ease Cubic Out
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseCubicActionOut);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseCubicActionInOut
|
|
|
|
@brief Ease Cubic InOut
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASE_TEMPLATE_DECL_CLASS(EaseCubicActionInOut);
|
|
|
|
|
|
|
|
//
|
|
|
|
// NOTE: Converting these macros into Templates is desirable, but please see
|
|
|
|
// issue #16159 [https://github.com/cocos2d/cocos2d-x/pull/16159] for further info
|
|
|
|
//
|
|
|
|
|
|
|
|
#define EASERATE_TEMPLATE_DECL_CLASS(CLASSNAME) \
|
|
|
|
class CC_DLL CLASSNAME : public EaseRateAction \
|
|
|
|
{ \
|
|
|
|
CC_CONSTRUCTOR_ACCESS: \
|
|
|
|
virtual ~CLASSNAME() { } \
|
|
|
|
CLASSNAME() { } \
|
|
|
|
public: \
|
|
|
|
static CLASSNAME* create(ActionInterval* action, float rate); \
|
2016-10-26 15:54:01 +08:00
|
|
|
virtual CLASSNAME* clone() const override; \
|
|
|
|
virtual void update(float time) override; \
|
|
|
|
virtual EaseRateAction* reverse() const override; \
|
2016-09-05 10:18:30 +08:00
|
|
|
private: \
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(CLASSNAME); \
|
2010-08-10 14:02:13 +08:00
|
|
|
};
|
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseIn
|
|
|
|
@brief EaseIn action with a rate.
|
|
|
|
@details The timeline of inner action will be changed by:
|
|
|
|
\f${ time }^{ rate }\f$.
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASERATE_TEMPLATE_DECL_CLASS(EaseIn);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseOut
|
|
|
|
@brief EaseOut action with a rate.
|
|
|
|
@details The timeline of inner action will be changed by:
|
|
|
|
\f${ time }^ { (1/rate) }\f$.
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASERATE_TEMPLATE_DECL_CLASS(EaseOut);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseInOut
|
|
|
|
@brief EaseInOut action with a rate
|
|
|
|
@details If time * 2 < 1, the timeline of inner action will be changed by:
|
|
|
|
\f$0.5*{ time }^{ rate }\f$.
|
|
|
|
Else, the timeline of inner action will be changed by:
|
|
|
|
\f$1.0-0.5*{ 2-time }^{ rate }\f$.
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASERATE_TEMPLATE_DECL_CLASS(EaseInOut);
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseElastic
|
|
|
|
@brief Ease Elastic abstract class
|
2010-08-10 14:02:13 +08:00
|
|
|
@since v0.8.2
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
class CC_DLL EaseElastic : public ActionEase
|
2010-08-10 14:02:13 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@brief Get period of the wave in radians. Default value is 0.3.
|
|
|
|
@return Return the period of the wave in radians.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
float getPeriod() const { return _period; }
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@brief Set period of the wave in radians.
|
|
|
|
@param fPeriod The value will be set.
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
void setPeriod(float fPeriod) { _period = fPeriod; }
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2014-03-28 17:45:06 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2016-09-05 10:18:30 +08:00
|
|
|
EaseElastic() {}
|
|
|
|
virtual ~EaseElastic() {}
|
|
|
|
/**
|
|
|
|
@brief Initializes the action with the inner action and the period in radians.
|
|
|
|
@param action The pointer of the inner action.
|
|
|
|
@param period Period of the wave in radians. Default is 0.3.
|
|
|
|
@return Return true when the initialization success, otherwise return false.
|
|
|
|
*/
|
|
|
|
bool initWithAction(ActionInterval *action, float period = 0.3f);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
float _period;
|
2013-11-22 09:06:06 +08:00
|
|
|
|
|
|
|
private:
|
2016-09-05 10:18:30 +08:00
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(EaseElastic);
|
2010-08-10 14:02:13 +08:00
|
|
|
};
|
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
//
|
|
|
|
// NOTE: Converting these macros into Templates is desirable, but please see
|
|
|
|
// issue #16159 [https://github.com/cocos2d/cocos2d-x/pull/16159] for further info
|
|
|
|
//
|
|
|
|
#define EASEELASTIC_TEMPLATE_DECL_CLASS(CLASSNAME) \
|
|
|
|
class CC_DLL CLASSNAME : public EaseElastic \
|
|
|
|
{ \
|
|
|
|
CC_CONSTRUCTOR_ACCESS: \
|
|
|
|
virtual ~CLASSNAME() { } \
|
|
|
|
CLASSNAME() { } \
|
|
|
|
public: \
|
|
|
|
static CLASSNAME* create(ActionInterval* action, float rate = 0.3f); \
|
2016-10-26 15:54:01 +08:00
|
|
|
virtual CLASSNAME* clone() const override; \
|
|
|
|
virtual void update(float time) override; \
|
|
|
|
virtual EaseElastic* reverse() const override; \
|
2016-09-05 10:18:30 +08:00
|
|
|
private: \
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(CLASSNAME); \
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class EaseElasticIn
|
|
|
|
@brief Ease Elastic In action.
|
|
|
|
@details If time == 0 or time == 1, the timeline of inner action will not be changed.
|
|
|
|
Else, the timeline of inner action will be changed by:
|
|
|
|
\f$-{ 2 }^{ 10*(time-1) }*sin((time-1-\frac { period }{ 4 } )*\pi *2/period)\f$.
|
|
|
|
|
2015-03-18 18:15:34 +08:00
|
|
|
@warning This action doesn't use a bijective function.
|
2016-09-05 10:18:30 +08:00
|
|
|
Actions like Sequence might have an unexpected result when used with this action.
|
2010-08-10 14:02:13 +08:00
|
|
|
@since v0.8.2
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2010-08-10 14:02:13 +08:00
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
EASEELASTIC_TEMPLATE_DECL_CLASS(EaseElasticIn);
|
2013-07-16 03:43:22 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseElasticOut
|
|
|
|
@brief Ease Elastic Out action.
|
|
|
|
@details If time == 0 or time == 1, the timeline of inner action will not be changed.
|
|
|
|
Else, the timeline of inner action will be changed by:
|
|
|
|
\f${ 2 }^{ -10*time }*sin((time-\frac { period }{ 4 } )*\pi *2/period)+1\f$.
|
|
|
|
@warning This action doesn't use a bijective function.
|
|
|
|
Actions like Sequence might have an unexpected result when used with this action.
|
|
|
|
@since v0.8.2
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASEELASTIC_TEMPLATE_DECL_CLASS(EaseElasticOut);
|
2013-11-22 09:06:06 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseElasticInOut
|
|
|
|
@brief Ease Elastic InOut action.
|
|
|
|
@warning This action doesn't use a bijective function.
|
|
|
|
Actions like Sequence might have an unexpected result when used with this action.
|
|
|
|
@since v0.8.2
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
EASEELASTIC_TEMPLATE_DECL_CLASS(EaseElasticInOut);
|
2010-08-10 14:02:13 +08:00
|
|
|
|
2014-02-17 11:20:01 +08:00
|
|
|
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
|
|
|
@class EaseBezierAction
|
|
|
|
@brief Ease Bezier
|
|
|
|
@ingroup Actions
|
|
|
|
*/
|
|
|
|
class CC_DLL EaseBezierAction : public cocos2d::ActionEase
|
2014-02-17 11:20:01 +08:00
|
|
|
{
|
|
|
|
public:
|
2016-09-05 10:18:30 +08:00
|
|
|
/**
|
2015-03-18 18:15:34 +08:00
|
|
|
@brief Create the action with the inner action.
|
|
|
|
@param action The pointer of the inner action.
|
|
|
|
@return A pointer of EaseBezierAction action. If creation failed, return nil.
|
|
|
|
*/
|
2016-09-05 10:18:30 +08:00
|
|
|
static EaseBezierAction* create(cocos2d::ActionInterval* action);
|
|
|
|
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual EaseBezierAction* clone() const override;
|
|
|
|
virtual EaseBezierAction* reverse() const override;
|
2014-02-17 11:20:01 +08:00
|
|
|
|
2015-03-18 18:15:34 +08:00
|
|
|
/**
|
2016-09-05 10:18:30 +08:00
|
|
|
@brief Set the bezier parameters.
|
2015-03-18 18:15:34 +08:00
|
|
|
*/
|
2014-07-18 14:53:00 +08:00
|
|
|
virtual void setBezierParamer( float p0, float p1, float p2, float p3);
|
2014-02-17 11:20:01 +08:00
|
|
|
|
2014-03-28 17:45:06 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2014-07-18 14:53:00 +08:00
|
|
|
EaseBezierAction() {}
|
|
|
|
virtual ~EaseBezierAction() {}
|
2014-02-17 11:20:01 +08:00
|
|
|
|
2014-03-28 17:45:06 +08:00
|
|
|
protected:
|
2014-07-18 14:53:00 +08:00
|
|
|
float _p0;
|
|
|
|
float _p1;
|
|
|
|
float _p2;
|
|
|
|
float _p3;
|
2014-02-17 11:20:01 +08:00
|
|
|
|
|
|
|
private:
|
2014-07-18 14:53:00 +08:00
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(EaseBezierAction);
|
2014-02-17 11:20:01 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of actions group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_END
|
2012-01-12 17:06:46 +08:00
|
|
|
|
|
|
|
#endif // __ACTION_CCEASE_ACTION_H__
|